Conditional total
SUMIF(range, criteria, sum_range) or SUMIFS(sum_range, criteria_range, criteria, ...)
One condition is SUMIF. Two or more, all required, are SUMIFS with the numbers first.
Interview formula questions usually ask you to total a category, look up an exact key, label a row with IF, and count workdays. Answer with a formula, not a typed number. On the sheets below, East sales are 60, Book's price is 12, an East score of 82 gets a bonus, and 2 January through 12 January 2024 with a Monday holiday is 8 workdays.
SUMIF(range, criteria, sum_range) or SUMIFS(sum_range, criteria_range, criteria, ...)
One condition is SUMIF. Two or more, all required, are SUMIFS with the numbers first.
XLOOKUP(...) or VLOOKUP(..., FALSE) or INDEX(..., MATCH(..., 0))
Say which Excel versions the file must survive, then pick the function. FALSE or 0 is the exact match. Do not leave VLOOKUP's fourth argument out.
IF(AND(...), true_value, false_value)
One cutoff is IF. Two requirements on the same label are AND or OR inside IF. Several different labels are IFS or a nested IF.
NETWORKDAYS(start, end, holidays)
Inclusive of the ends, weekends excluded, holidays removed when they fall on workdays.
| Question | What they hand you | What you type | A wrong answer that looks close |
|---|---|---|---|
| Total for one region | A category column and an amount column | SUMIF or SUMIFS | SUM of the whole column |
| Price for a product | A key and a table | Exact XLOOKUP, VLOOKUP with FALSE, or INDEX/MATCH | VLOOKUP with TRUE, or a typed 12 |
| Bonus rule | A score and a region | IF with AND | IF on the score only |
| Days until a deadline | Two dates and a holiday | NETWORKDAYS | End minus start |
You are asked for East only. The sheet has West as well. The full column is 100. The East rows are 10, 30, and 20.
| Row | A | B | C |
|---|---|---|---|
| 1 | Region | Product | Amount |
| 2 | East | Pen | 10 |
| 3 | West | Pen | 40 |
| 4 | East | Book | 30 |
| 5 | East | Pen | 20 |
=SUMIF(A2:A5,"East",C2:C5) → 60=SUM(C2:C5) → 10060 is the East total. 100 is every order, which answers a different question. If the interviewer adds 'and only Pens', switch to SUMIFS with the amount first and a second pair for the product. That result on this sheet is 30.
The product to find is Book. A nearby product is not acceptable. Mention FALSE if you use VLOOKUP.
| Row | A | B | C | D | E |
|---|---|---|---|---|---|
| 1 | Product | Price | Qty | Find | |
| 2 | Pen | 1.5 | 4 | Book | |
| 3 | Book | 12 | 2 | ||
| 4 | Lamp | 24 | 1 |
=XLOOKUP(E2,A2:A4,B2:B4) → 12=VLOOKUP(E2,A2:B4,2,FALSE) → 12Both return 12. Talk through the column index if you chose VLOOKUP: the table starts on the product, and the price is the second column. If they ask for the product name given the price, say that VLOOKUP cannot look left and switch to XLOOKUP or INDEX/MATCH.
The rule is at least 70 and East. 82 East qualifies. Do not stop at the score.
| Row | A | B |
|---|---|---|
| 1 | ||
| 2 | 82 | East |
=IF(AND(A2>=70,B2="East"),"Bonus","No") → BonusAND makes both tests required. A 90 in another region would be No. Say that aloud. It shows you heard the whole rule.
From 2 January 2024 through 12 January 2024, excluding 8 January 2024. The interviewer wants business days, not calendar days.
| Row | A | B | C | D |
|---|---|---|---|---|
| 1 | Start | End | Holiday | |
| 2 | 2024-01-02 | 2024-01-12 | 2024-01-08 | |
| 3 | 2024-01-06 | 2024-01-07 | ||
| 4 | 2024-03-01 | 2024-03-15 | 2024-03-08 | 2024-03-11 |
=NETWORKDAYS(A2,B2,C2) → 8Nine weekdays sit in that window, and the Monday holiday removes one, leaving 8. Mention that the start and end count, and that a holiday on a Saturday would not.
Say which range is tested and which range is added. Say FALSE. Say that AND means both. Interviewers are often checking whether you can explain a formula you typed under a time limit.
XLOOKUP is the right modern answer and a #NAME? error in Excel 2019. If they do not know the version, give VLOOKUP with FALSE or INDEX/MATCH and mention XLOOKUP as the current equivalent.
Formula Drills marks a formula wrong when the value is right but the function is missing, and it marks a typed constant wrong. The free drills cover SUM, IF, COUNTIF, and references. The premium drills cover the lookup and the workday questions.
12 is the price. The answer they can reuse next week is the formula. A hardcoded 12 breaks as soon as Book's price changes.
100 includes West. If the question named a category, the category has to be in the formula.
The default is an approximate match. For a product name, that is the wrong default. Type FALSE.
Calendar subtraction counts Saturdays and ignores the holiday list. NETWORKDAYS is the function that matches the question.
SUMIF, IF, AND, VLOOKUP, and NETWORKDAYS are safe answers in older Excel and in Google Sheets. XLOOKUP is safe in Excel 2021, Microsoft 365, and Google Sheets, and it is a #NAME? error in Excel 2019.
None of these questions requires a macro. If the interviewer asks for one, a formula is still the right first offer when a formula can do it.
Google Sheets uses the same function names for everything on this page except that a locale may want semicolons between arguments.
Free drills are open with no account. Premium drills show the problem to everyone and grade the sheet for subscribers.
There is no single exam. Teams ask for the formulas their workbooks use. The four on this page are a fair core: a conditional total, an exact lookup, a combined test, and workdays. Practice those until you can type them without looking up the argument order.
Yes. Name the range you are testing and the range you are returning. Correcting yourself out loud is better than a silent wrong column index.
Say that the numbers come first in SUMIFS and last in SUMIF, then write the one you remember cleanly. A correct SUMIF plus a sentence about the second condition is stronger than a SUMIFS with the ranges backwards.
Often, as a separate skill. This page is about formulas. A pivot does not replace being able to write SUMIF when the total has to live in a cell the rest of the model reads.