Excel Practice Test

โ–ถ

The IF function in Excel is the most-used logical function and one of the first formulas most users learn beyond simple SUM and AVERAGE. The syntax is straightforward: =IF(condition, value_if_true, value_if_false). The function checks whether a condition is met and returns one value if true or another if false. From this simple foundation, Excel builds up to nested IFs, the IFS function (cleaner for multiple conditions), and combinations with AND/OR for compound logic.

Basic example: =IF(A1>100, "Over Budget", "Within Budget"). If cell A1 has a value greater than 100, the formula returns "Over Budget"; otherwise it returns "Within Budget". The condition can be any comparison or logical expression that evaluates to TRUE or FALSE. The return values can be text (in quotes), numbers, cell references, or even other formulas.

The most common confusion with IF is forgetting that text values need to be in quotes. =IF(A1>100, Over Budget, Within Budget) returns a #NAME error because Excel treats "Over Budget" as variable names rather than text. =IF(A1>100, "Over Budget", "Within Budget") works correctly. Numbers don't need quotes โ€” =IF(A1>100, 1, 0) returns 1 or 0 as numeric values.

Nested IF โ€” placing one IF inside another โ€” is how you handle more than two conditions. Example: =IF(A1>=90, "A", IF(A1>=80, "B", IF(A1>=70, "C", "F"))). This evaluates A1: if 90+, return "A"; otherwise check if 80+, return "B"; otherwise check 70+, return "C"; otherwise return "F". Nested IFs work but get unwieldy past 3-4 levels. The IFS function (Excel 2019+) is cleaner for multiple conditions.

IFS syntax: =IFS(condition1, value1, condition2, value2, ..., TRUE, default_value). The grade example becomes =IFS(A1>=90, "A", A1>=80, "B", A1>=70, "C", TRUE, "F"). The TRUE at the end is a catch-all for when no other condition matched โ€” equivalent to the "else" of an if/else if/else chain. IFS handles up to 127 conditions and is much more readable than deeply nested IFs.

For compound conditions, combine IF with AND or OR. =IF(AND(A1>0, A1<100), "Valid", "Invalid") requires both A1>0 AND A1<100 to return "Valid". =IF(OR(A1="Yes", A1="Y"), TRUE, FALSE) returns TRUE if A1 equals either "Yes" or "Y". AND and OR can take up to 255 logical arguments and return a single TRUE/FALSE that IF uses for its condition.

This guide covers IF function basics, nested IFs and when to use them, the IFS function, IF with AND/OR for compound conditions, IFERROR for error handling, common mistakes and how to fix them, and when to use IF vs. other approaches like VLOOKUP or SWITCH.

Excel IF Function Quick Reference
  • Basic syntax: =IF(condition, value_if_true, value_if_false)
  • Comparison operators: = (equals), <> (not equals), >, <, >=, <=
  • Text values: Must be in quotes ("text"). Numbers don't need quotes.
  • Nested IFs: =IF(A>=90,"A",IF(A>=80,"B",IF(A>=70,"C","F"))). Up to 64 levels but get unwieldy past 3-4.
  • IFS function (cleaner): =IFS(cond1,val1, cond2,val2, ..., TRUE,default). Excel 2019+.
  • AND/OR: =IF(AND(A>0,A<100),"OK","NO") or =IF(OR(A="Yes",A="Y"),TRUE,FALSE)
  • IFERROR: =IFERROR(formula, error_value) โ€” wraps formulas to handle errors gracefully
  • Common error: Forgetting quotes around text values produces #NAME error
Try a Free Excel Practice Test

IF function comparison operators give you the tools to express most common conditions. Equal: A1=100 or A1="Yes". Not equal: A1<>100 (the <> is two characters together, like a typographic "not equal" sign). Greater than: A1>100. Less than: A1<100. Greater than or equal: A1>=100. Less than or equal: A1<=100. These work with numbers and dates straightforwardly; with text, alphabetical comparisons are used (case-insensitive by default).

Date comparisons work because Excel stores dates as serial numbers. =IF(A1>=DATE(2026,1,1), "This Year", "Last Year") evaluates whether A1 is on or after January 1, 2026. The DATE function inside the condition handles regional format issues that arise from hard-coded date strings. Comparing two cells: =IF(A1>B1, "A is bigger", "B is bigger or equal") returns the comparison between two cells.

Wildcards don't work in IF function conditions directly. =IF(A1="*West*", "Yes", "No") doesn't do partial matching โ€” it looks for the literal text "*West*". For partial matching, use SEARCH or FIND functions: =IF(ISNUMBER(SEARCH("West", A1)), "Yes", "No") returns "Yes" if A1 contains "West" anywhere. SEARCH is case-insensitive; FIND is case-sensitive.

Numeric tolerance issues affect IF conditions involving calculated values. =IF(A1=B1, ...) may return FALSE even when A1 and B1 "look" equal because of tiny floating-point differences (0.1 + 0.2 = 0.30000000000000004 in floating-point arithmetic). For numbers that may have precision issues, use =IF(ABS(A1-B1)<0.001, "Equal", "Different") โ€” compare absolute difference to a small tolerance instead of exact equality.

Empty cell handling: =IF(A1="", "Empty", "Has Value") doesn't work as expected for cells that have never been written to. A1="" only matches cells with empty-string content, not blank cells. For truly blank cells, use ISBLANK: =IF(ISBLANK(A1), "Empty", "Has Value"). The distinction matters when checking results from formulas that may return empty strings vs. when checking actual blank cells.

One IF pattern that confuses new users: =IF(condition) without a value_if_false. Excel allows omitting the value_if_false (returns FALSE by default), but this often produces unexpected results. =IF(A1>100, "Over") returns "Over" when A1>100 and FALSE otherwise โ€” the literal Boolean FALSE, not blank. To return blank instead, write =IF(A1>100, "Over", ""). Better still, always include both arguments explicitly for clarity.

Common IF Patterns

๐Ÿ”ด Threshold Check

=IF(A1>=1000, "Premium", "Standard"). Two-way classification based on a numeric threshold.

๐ŸŸ  Yes/No to Boolean

=IF(A1="Yes", TRUE, FALSE). Converts text answers to Boolean for further calculation.

๐ŸŸก Grade Assignment

=IFS(A1>=90,"A", A1>=80,"B", A1>=70,"C", TRUE,"F"). Multi-tier classification using IFS function.

๐ŸŸข Range Check

=IF(AND(A1>=0, A1<=100), "Valid", "Out of Range"). Combines IF with AND for between-values check.

๐Ÿ”ต Either-Or Check

=IF(OR(A1="Active", A1="Pending"), "Open", "Closed"). Combines IF with OR for multiple acceptable values.

๐ŸŸฃ Error Handling

=IFERROR(B1/A1, "N/A"). Returns "N/A" if the division produces an error (like division by zero) instead of showing #DIV/0!.

Nested IFs vs. IFS function: when to use which? Nested IF works in all Excel versions including very old ones. =IF(A1>=90, "A", IF(A1>=80, "B", IF(A1>=70, "C", "F"))) gets the job done. The downside is readability โ€” past 3-4 nested levels, the formula becomes hard to follow and hard to edit. Adding a new grade tier (like "D" between C and F) requires careful repositioning of parentheses.

IFS (Excel 2019+) is much cleaner. =IFS(A1>=90, "A", A1>=80, "B", A1>=70, "C", A1>=60, "D", TRUE, "F") reads top-to-bottom: first condition met returns its value. The TRUE catch-all at the end handles the "else" case. Adding a new tier means inserting one condition/value pair โ€” much easier than restructuring nested IFs.

For backward compatibility (files opened in older Excel), nested IFs are necessary. If you're certain everyone has Excel 2019+ or Microsoft 365, prefer IFS for new formulas. For mixed-version environments, nested IF remains the safer choice.

IFERROR is the error-handling wrapper for IF logic. =IFERROR(A1/B1, 0) returns 0 instead of #DIV/0! if B1 is zero. =IFERROR(VLOOKUP(...), "Not Found") returns "Not Found" instead of #N/A if the lookup fails. IFERROR replaces older patterns like =IF(ISERROR(formula), error_value, formula) โ€” much cleaner. Use IFERROR liberally around formulas that may produce errors to keep your worksheet clean of red error displays.

SWITCH function is another alternative for multi-value logic, similar to switch/case in programming. =SWITCH(A1, "Mon", 1, "Tue", 2, "Wed", 3, "Thu", 4, "Fri", 5, 0) returns 1-5 based on A1's value, with 0 as default. SWITCH works well when you're mapping specific values to specific outputs (exact matches only); IFS works better when you have ranges or comparisons. Both are cleaner than nested IFs for their respective use cases.

VLOOKUP and XLOOKUP can replace some IF logic. If your conditions are exact-match lookups (department X โ†’ manager Y, product code Z โ†’ price A), a lookup function with a reference table is cleaner than nested IFs. The IF approach scales badly; the lookup approach scales arbitrarily. Use IF for inline logic; use lookups for data that should live in a separate reference table.

Advanced IF Patterns

๐Ÿ“‹ IF + AND/OR

  • AND: All conditions must be true. =IF(AND(A>0, B>0, C>0), "All Positive", "Has Zero or Negative")
  • OR: At least one condition must be true. =IF(OR(A="Pending", B="Pending"), "In Progress", "Done")
  • NOT: Reverses a condition. =IF(NOT(ISBLANK(A1)), "Filled", "Empty")
  • Nested AND/OR: =IF(AND(A>0, OR(B="X", B="Y")), "Match", "No Match") for complex compound logic
  • Practical use: Approval workflows (all approvers must approve), validation (any required field must be filled), filtering (combine multiple criteria)

๐Ÿ“‹ Nested IF Best Practices

  • Order conditions: Put most-likely-to-match conditions first for performance
  • Limit depth: Beyond 3-4 nested levels, use IFS, SWITCH, or VLOOKUP instead
  • Indent for readability: Format formula with line breaks (Alt+Enter inside formula bar) when complex
  • Add comments: Use Name Manager defined names with descriptive names for complex logic
  • Test edge cases: Values at threshold boundaries, blank cells, error values โ€” all should behave predictably
  • Consider helper cells: Break complex logic across multiple cells for clarity and debuggability

๐Ÿ“‹ IFS Function (Cleaner Alternative)

Syntax: =IFS(cond1, val1, cond2, val2, ..., TRUE, default)

  • Available in: Excel 2019, Microsoft 365, Google Sheets
  • Order matters: Conditions evaluated left to right; first match wins
  • Default case: Use TRUE as final condition for else/default value
  • Max conditions: 127 condition/value pairs
  • Backward compatibility: Files saved with IFS won't open correctly in pre-2019 Excel โ€” use nested IF if compatibility needed

๐Ÿ“‹ IF Error Handling

  • IFERROR: =IFERROR(formula, value_if_error). Returns value_if_error if formula produces ANY error.
  • IFNA: =IFNA(formula, value_if_na). Like IFERROR but only handles #N/A specifically.
  • ISERROR/ISERR: Returns TRUE if cell has error. Use inside IF for conditional error handling.
  • Common pattern: =IFERROR(VLOOKUP(A1, RefTable, 2, FALSE), "Not Found") to handle lookup failures gracefully
  • Excessive IFERROR: Can mask real bugs. Use only where errors are expected and have meaningful handling.
Practice Excel Formula Questions

Common IF function mistakes and how to avoid them. Mistake 1: forgetting quotes around text. =IF(A1>100, Over Budget, Within Budget) โ†’ #NAME error. Fix: =IF(A1>100, "Over Budget", "Within Budget"). Always quote text values.

Mistake 2: comparing text and numbers. =IF(A1=100, "Match", "No Match") might return "No Match" even when A1 displays "100" because A1 contains text "100" rather than number 100. Fix: =IF(VALUE(A1)=100, ...) to coerce text to number, or =IF(A1="100", ...) to compare as text. Better: ensure A1 actually contains numbers (use VALUE during import).

Mistake 3: using = where you mean ==. Other programming languages use == for equality; Excel uses single =. =IF(A1==100, ...) is invalid syntax. Just =IF(A1=100, ...) is correct.

Mistake 4: parenthesis errors in nested IFs. =IF(A1>10, "big", IF(A1>5, "medium", "small") missing the closing parenthesis at the end. Fix: count opening vs. closing parens. Excel's formula bar color-codes paired parens to help you match them visually.

Mistake 5: using IF when a lookup function is cleaner. =IF(A1="Mon", 1, IF(A1="Tue", 2, IF(A1="Wed", 3, IF(A1="Thu", 4, 5)))) โ†’ better as =SWITCH(A1, "Mon", 1, "Tue", 2, "Wed", 3, "Thu", 4, 5) or =MATCH(A1, {"Mon","Tue","Wed","Thu","Fri"}, 0). For data mappings, lookups beat nested IFs.

Mistake 6: returning different data types from each branch. =IF(A1>0, 1, "Negative") returns a number sometimes and text other times. Downstream formulas referencing this cell may break unpredictably. Fix: return consistent data types โ€” either always numbers (use 0 instead of "Negative") or always text (use "1" instead of 1).

Mistake 7: nested IFs that don't cover all cases. =IF(A1>90, "A", IF(A1>80, "B", "C")) doesn't return "D" or "F" for low scores. Fix: think through all possible value ranges before writing the formula. IFS with a TRUE catch-all is cleaner: =IFS(A1>=90,"A", A1>=80,"B", A1>=70,"C", A1>=60,"D", TRUE,"F").

IF function performance: IF is fast on small worksheets but can slow down on large data sets with deeply nested formulas. Two specific performance considerations matter. First, IF formulas in tens of thousands of cells each referencing entire columns (=IF(A:A>100, ...) instead of =IF(A2:A100>100, ...)) cause slow recalculation. Specifying actual ranges helps performance.

Second, volatile functions inside IF (like TODAY(), NOW(), or RAND()) cause the IF to recalculate on every change to anything in the workbook. =IF(A1<TODAY(), "Overdue", "OK") in many rows can slow large workbooks. If you need date-comparison logic that doesn't need to update in real time, replace TODAY() with a cell that holds a manually-updated "as of" date.</p>

IF with array formulas creates more complex patterns. In Microsoft 365, =IF(A1:A100>100, B1:B100, 0) operates element-wise on the arrays and returns an array of results that spills into adjacent cells. This is the modern dynamic-array behavior. In older Excel, the same formula needed to be entered with Ctrl+Shift+Enter to create an array formula. Either way, IF can operate on arrays for bulk conditional logic.

Combining IF with SUMIFS/COUNTIFS: when you need conditional aggregation, prefer SUMIFS/COUNTIFS over IF + SUM. =SUMIFS(B:B, A:A, ">100") is faster and cleaner than =SUM(IF(A:A>100, B:B, 0)) entered as array formula. The same goes for COUNTIFS vs. SUM(IF(...)). Use IF for per-cell conditional logic; use IFS/COUNTIFS/SUMIFS for aggregated conditional logic.

IF + INDEX/MATCH or VLOOKUP combinations are powerful for conditional lookups. =IF(A1="Premium", VLOOKUP(B1, PremiumTable, 2, FALSE), VLOOKUP(B1, StandardTable, 2, FALSE)) chooses which reference table to look up in based on a condition. This pattern is useful when you have different pricing tiers, different geographic mappings, or different rule sets based on a discriminator.

For formulas that need to be very robust (used in production reports, financial models, regulatory filings), wrap your IF formulas in IFERROR with a meaningful default and document the expected error cases. =IFERROR(IF(complex_logic), default_value) handles unexpected error states without breaking downstream calculations. Document why IFERROR is needed (with a cell comment if necessary) so future maintainers understand the expected error handling.

When to Use Each Logic Function

๐Ÿ”ด Single IF (Two-Way)

Use when you have one condition producing one of two values. =IF(A>100, "High", "Low"). Cleanest for binary logic.

๐ŸŸ  Nested IF (Multi-Way, Old Excel)

Use for backward compatibility with Excel pre-2019. Limit to 3-4 nesting levels. Order conditions for performance and readability.

๐ŸŸก IFS (Multi-Way, 2019+)

Cleaner than nested IF for 3+ conditions. =IFS(cond1,val1, cond2,val2, TRUE,default). Easy to read and modify.

๐ŸŸข SWITCH (Exact Match)

Best for mapping specific values to specific outputs. =SWITCH(A, "X",1, "Y",2, "Z",3). Cleaner than nested IF for exact-match scenarios.

๐Ÿ”ต VLOOKUP/XLOOKUP

Best for data lookups in reference tables. More maintainable than nested IF when the mapping data should live separately from the formula.

๐ŸŸฃ IFERROR Wrapper

Always consider wrapping IF formulas that may produce errors. =IFERROR(formula, fallback) keeps worksheets clean of error displays.

Mastering IF Function

1

=IF(condition, value_if_true, value_if_false). Practice with simple two-way comparisons until automatic. Get comfortable with quoting text values.

2

=, <>, >, <, >=, <=. Practice each. Understand date and text comparisons. Learn ISBLANK for empty cell checks.

3

=IF(AND(A>0,B>0), ...). Master compound conditions. Practice nested AND/OR for complex logic before nesting IFs.

4

Up to 3 levels deep. Practice grade-assignment style problems. Understand the order of evaluation and parenthesis matching.

5

Once you have Excel 2019+, replace nested IFs with IFS. Faster to write, easier to maintain. Use TRUE as final catch-all.

6

Wrap formulas that may produce errors in IFERROR. Provide meaningful default values. Avoid masking real bugs with blanket IFERROR.

Dynamic array IF in Microsoft 365 changes how IF works at scale. =IF(A2:A100>100, "High", "Low") in Microsoft 365 returns an array of 99 values that spills into adjacent cells. The same formula in older Excel returned only the first value unless entered as an array formula with Ctrl+Shift+Enter. Modern Excel's dynamic arrays make IF more naturally array-aware, which simplifies many bulk-operation formulas.

Combined with FILTER, the dynamic array IF becomes very powerful. =FILTER(A2:C100, IF(D2:D100>100, TRUE, FALSE)) returns rows of A2:C100 where the corresponding D column value exceeds 100. The dynamic array IF generates the filter mask; FILTER applies it. This is a cleaner pattern than older array formula approaches for selective row display.

IF function in Power Query (Get & Transform): Power Query uses a similar but slightly different syntax. In M code, the function is `if condition then value_if_true else value_if_false`. Same logic but expressed differently. Power Query's IF is generally more robust for data transformation pipelines but requires learning Power Query M language.

IF in Excel macros and VBA: VBA has its own If/Then/Else structure that's separate from the worksheet IF function. VBA code like `If condition Then value = x Else value = y` operates on variables, not cells. The two are unrelated despite the similar names. VBA macros can read and write IF-based formulas to cells, but the VBA If is for procedural control flow rather than spreadsheet calculation.

For learners, the practical progression is: master basic IF first, learn AND/OR combinations, get comfortable with nested IFs up to 3 levels, then transition to IFS for cleaner multi-way logic. Eventually replace IF chains with lookups (VLOOKUP, XLOOKUP) when the data is more appropriately stored in reference tables. Each step is a real productivity gain; don't try to skip ahead before mastering the basics.

IF Pros and Cons

Pros

  • IF has a publicly available content blueprint โ€” you know exactly what to prepare for
  • Multiple preparation pathways accommodate different schedules and budgets
  • Clear score reporting shows specific strengths and weaknesses
  • Study communities share current insights from recent test-takers
  • Retake policies allow recovery from a difficult first attempt

Cons

  • Tested content scope requires substantial preparation time
  • No single resource covers everything optimally
  • Exam-day performance can differ from practice test performance
  • Registration, prep, and retake costs accumulate significantly
  • Content changes between versions can make older materials less reliable

EXCEL Questions and Answers

What's the basic syntax of Excel IF?

=IF(condition, value_if_true, value_if_false). The condition is any comparison or logical test that returns TRUE/FALSE. Text values must be in quotes; numbers don't need quotes. Example: =IF(A1>100, "Over Budget", "Within Budget").

How do I write a nested IF in Excel?

Put one IF inside the value_if_false (or value_if_true) of another. Example: =IF(A1>=90, "A", IF(A1>=80, "B", IF(A1>=70, "C", "F"))). Each nested IF handles a tier of conditions. Limit nesting to 3-4 levels; deeper nesting becomes unmaintainable. Consider IFS function for cleaner multi-condition logic.

What's the difference between IF and IFS?

IF handles one condition with two outcomes. IFS (Excel 2019+) handles multiple conditions cleanly. IFS syntax: =IFS(cond1, val1, cond2, val2, ..., TRUE, default). The TRUE catch-all is the equivalent of else. IFS is much more readable for 3+ conditions than nested IFs.

How do I use IF with AND/OR?

Wrap the condition in AND() or OR(). Example AND: =IF(AND(A>0, B>0), "Both Positive", "At Least One Zero or Negative"). Example OR: =IF(OR(A="Yes", A="Y"), TRUE, FALSE). AND requires all conditions true; OR requires at least one. Both can take up to 255 logical arguments.

Why does my IF formula return #NAME?

Most common cause: forgetting quotes around text values. =IF(A1>100, Over Budget, Within Budget) treats "Over Budget" as a variable name (which doesn't exist). Fix: =IF(A1>100, "Over Budget", "Within Budget"). Other causes: misspelled function name, undefined cell references, missing closing parenthesis.

Can I use IF to handle errors?

Use IFERROR or IFNA instead of IF for error handling โ€” they're cleaner. =IFERROR(A1/B1, 0) returns 0 if the division produces any error (like #DIV/0!). =IFNA(VLOOKUP(...), "Not Found") returns "Not Found" only if VLOOKUP produces #N/A. Wrap formulas that may produce errors in IFERROR for graceful fallback values.

When should I use VLOOKUP instead of nested IF?

When you're mapping data values โ€” department codes to names, product codes to prices, employee IDs to managers. Store the mapping in a reference table and use VLOOKUP/XLOOKUP. Nested IFs become unmaintainable past 5-6 mappings. The lookup approach scales to hundreds of mappings without formula complexity changes.
Take the Full Excel Practice Test

The IF function is one of those tools where mastery comes from knowing when NOT to use it as much as knowing how to use it. Single IFs for binary decisions, IFS or SWITCH for cleaner multi-way logic, VLOOKUP/XLOOKUP for data mappings, IFERROR for graceful error handling. Each tool has its place, and choosing the right one keeps your spreadsheets maintainable as they grow.

For most users, the IF mastery progression is: basic IF first, then add AND/OR for compound conditions, then IFERROR for robustness, then transition to IFS for multi-way logic when Excel 2019+ is available. Beyond that, the path leads to lookups and structured data approaches that don't rely on IF at all. The most maintainable spreadsheets are usually the ones that minimize complex IF formulas in favor of reference tables and lookups โ€” the formulas become simple, and the data becomes more visible.

A practical productivity habit worth adopting: when you find yourself writing more than two levels of nested IF, stop and ask whether the data should be in a lookup table instead. The IF formula will work but the result will be harder to update later. A reference table with VLOOKUP or XLOOKUP makes the mapping data visible and editable as data rather than buried inside formula syntax. Future you will thank present you for choosing the lookup approach when business rules change six months from now.

Similarly, when you find yourself writing the same complex IF logic in multiple cells across a worksheet, consider extracting it to a helper column or defined name. A defined name like ProductTier (pointing at your complex IF logic) makes downstream formulas read as =IF(ProductTier="Gold", ...) instead of =IF(IF(complex stuff)="Gold", ...). Defined names are one of the more underused Excel features and they directly improve formula readability and maintenance.

For shared workbooks and collaborative editing, simpler formulas matter more than terse ones. A 5-cell helper-column approach that a colleague can read and modify is better than a single-cell nested IF that requires careful parsing. The principle: optimize for the human reading and editing the formula six months from now, not for the elegance of fitting everything in one cell. Excel rewards clarity in maintenance even when it costs a few extra cells in the design.

โ–ถ Start Quiz