Practice problems / Lookup & Reference

Default to zero on missing discount (VLOOKUP + IFERROR)

Medium Lookup & Reference
Description
Hints 0/4
Solutions 2
–
Test case
1
2
3
Reset
Submit
fx
A
B
C
D
E
F
G
1
2
3
4
5
6
7
8
9
10
Loading interactive spreadsheet...
Preparing grid cells and formula calculation engine
○ Ready Enter formula in highlighted cells, then click Submit.

The problem

Problem statement

You are processing store checkouts. Members get a discount based on their VIP tier in A2:B5 (Bronze 5%, Silver 10%, Gold 15%, Platinum 20%). Non-VIP customers have standard tiers like 'Regular' or 'None' that are NOT in the VIP table, causing a naked VLOOKUP to fail with #N/A. Fill the Discount cells E2:E5 using VLOOKUP wrapped in IFERROR (or IFNA) so missing tiers safely default to 0.

The fallback must be the number 0, not the text "0" — case 2's non-VIP tier still feeds later arithmetic.

Problem data

Show the sheet as a table (selectable, copyable)
The exercise data, as a table
ABDE
1 VIP TierDiscountMember TierDiscount
2 Bronze0.05Gold
3 Silver0.1Regular
4 Gold0.15Silver
5 Platinum0.2None

Notes

When lookup outputs feed directly into arithmetic (e.g. Total * (1 - Discount)), returning a text like 'Not found' or letting #N/A bubble up will break the whole formula. Wrapping VLOOKUP in IFERROR with a 0 fallback keeps calculations running cleanly.

How to approach

Your answer goes in E2:E5. On submit we re-run your formula against 3 different sets of input, so a hardcoded number will fail — the formula has to follow the cells.

  1. Target cells are E2:E5 — start in E2, then fill down
  2. Build the core lookup first: VLOOKUP(D2, $A$2:$B$5, 2, FALSE)
  3. Wrap it in IFERROR: IFERROR(..., 0)
  4. Do not put quotes around 0 — it should be a numeric zero, not text

Official solutions

Show 2 solutions — try it yourself first

Approach 1: IFERROR with numeric zero fallback

=IFERROR(VLOOKUP(D2, $A$2:$B$5, 2, FALSE), 0)

If D2 exists in the VIP table, VLOOKUP returns the tier discount. If the customer is not a VIP (#N/A), IFERROR intercepts it and returns 0.

Approach 2: IFNA targeted lookup intercept

=IFNA(VLOOKUP(D2, $A$2:$B$5, 2, FALSE), 0)

IFNA specifically intercepts lookup misses (#N/A) without hiding formula syntax errors or broken table ranges (#REF!).

Function guide

Related practice

FAQ

Why return 0 instead of "No Discount"?

When the discount cell is later multiplied by the order amount (e.g. Price * (1 - Discount)), text causes a #VALUE! error. A numeric 0 allows subsequent math formulas to compute without errors.

Should I use IFERROR or IFNA for VLOOKUP?

IFNA is generally preferred for lookups because it only suppresses #N/A (lookup miss). IFERROR will also silence #REF! (deleted column), which could mask critical worksheet bugs.