Foxcolab
Skip to content

Use the IF function in Sheets, with examples

Use IF in Foxcolab Sheets to return one value when a condition is true and another when it's false, combine conditions with AND and OR, and replace nested IFs with IFS or SWITCH.

Updated 3 min read

In short

The IF function checks a condition and returns one value when it's true and another when it's false, as in =IF(D2>=C2, "Hit", "Missed"). Put text results in quotes. Combine conditions with AND or OR inside the test, use IFS for several outcomes in order, SWITCH to match exact values, and IFERROR to show something friendlier than an error.

Key takeaways

  • IF takes three parts: the test, the value if it's true, and the value if it's false. Leave out the last part and a false test shows FALSE.
  • Put text results in quotes. Use "" to leave a cell looking empty.
  • An empty cell counts as 0 in a number test, so check for blanks first with D2="".
  • IFS checks conditions in order and stops at the first true one. End it with TRUE and a default, or unmatched rows show
  • Text comparisons ignore capital letters. Use EXACT when case matters.

Last reviewed 5 December 2026

The IF function in Foxcolab Sheets checks a condition and returns one value when it's true and another when it's false. Use it to label rows ("Hit" or "Missed"), calculate only when it makes sense (a bonus above target) or hide a result until the data is in. Sheets calculates every formula in your browser, so your spreadsheet stays end-to-end encrypted while you work.

The examples use this sales list. Tom's sales cell is empty.

ABCD
1RepRegionTargetSales
2AshaNorth5000062000
3RaviSouth4000038500
4MeeraNorth4500045000
5TomWest30000
6DivyaSouth6000071000

Write an IF formula#

  1. Start the formula

    Click E2. Type =IF( or click Functions in the toolbar and choose IF.

  2. Add the three parts

    Type D2>=C2, "Hit", "Missed") so the cell reads =IF(D2>=C2, "Hit", "Missed"). The parts are the test, the value if it's true and the value if it's false.

  3. Fill it down

    Press Enter, then drag the fill handle in the corner of E2 down to E6. The column reads Hit, Missed, Hit, Missed, Hit.

The test can use =, <>, <, <=, > and >=. The results can be text in quotes, numbers or other formulas. This pays a 10% bonus on sales above target and 0 otherwise:

Text
=IF(D2>C2, (D2-C2)*0.1, 0)      → 1200, 0, 0, 0, 1100

Meera gets 0 because her sales equal her target and the test is "greater than".

Handle empty cells#

Tom shows Missed even though his sales aren't in. An empty cell counts as 0 in a number test, and 0 is below 30000. Check for a blank first:

Text
=IF(D2="", "", IF(D2>=C2, "Hit", "Missed"))

"" returns empty text, so Tom's row stays blank until someone types a number.

Combine conditions with AND and OR#

Put AND or OR inside the test. AND needs every condition to be true. OR needs at least one.

Text
=IF(AND(B2="North", D2>=C2), "Yes", "No")                 → Yes, No, Yes, No, No
=IF(OR(D2>=60000, D2-C2>=10000), "Bonus", "No bonus")     → Bonus, No bonus, No bonus, No bonus, Bonus

Text comparisons ignore capital letters, so B2="north" matches North. For a case-sensitive test, use EXACT(B2, "North").

Choose between several outcomes with IFS#

To grade each rep by how far past target they got, you can nest one IF inside another:

Text
=IF(D2/C2>=1.2, "A", IF(D2/C2>=1, "B", "C"))

IFS does the same in one flat list. It checks each condition in order and returns the value of the first one that's true:

Text
=IFS(D2/C2>=1.2, "A", D2/C2>=1, "B", TRUE, "C")           → A, C, B, C, B

The final TRUE, "C" is the default. Without it, Ravi and Tom match nothing and show #N/A. Order matters too: test the highest threshold first, or every rep over target stops at B.

When you're matching exact values rather than ranges, SWITCH is shorter:

Text
=SWITCH(B2, "North", "N-01", "South", "S-02", "Other")    → N-01, S-02, N-01, Other, S-02

Replace errors with IFERROR#

If a target cell were empty, =D2/C2 would show #DIV/0!. =IFERROR(D2/C2, "No target") shows No target instead and the real result everywhere else. IFNA does the same for #N/A only, which suits lookups. See XLOOKUP and VLOOKUP.

Common mistakes#

  • Text without quotes. =IF(D2>=C2, Hit, Missed) shows #NAME? because Sheets reads Hit as a name. Write "Hit".
  • FALSE in the cell. You left out the third part. Add "" or another value.
  • Numbers stored as text. Text always ranks above numbers in a comparison, so an imported "38500" counts as hitting any target. Re-enter the values as numbers, or use VALUE(D2) in the test.
  • A text cell as the whole test. =IF(B2, "Yes", "No") shows #VALUE! because North isn't true or false. Compare it with something, as in B2="North".
  • Semicolons instead of commas. If your spreadsheet's locale writes decimals with a comma, separate the parts with ;. Check Tools → Calculation & locale settings….

Frequently asked questions

How many IFs can I nest in Sheets?

Sheets doesn't set a small limit, but nested IFs get hard to read after two or three levels. IFS does the same job in one flat list of conditions, and SWITCH is shorter still when you're matching exact values.

Why does my IF formula show FALSE?

The test was false and you left out the third part. Add a value for that case, such as "" to show nothing, as in =IF(D2>=C2, "Hit", "").

Can IF check whether a cell contains certain text?

Not on its own, because a test like B2="North" needs the whole cell to match. Use COUNTIF with a wildcard as the test, as in =IF(COUNTIF(B2, "North"), "Yes", "No"), which is true when North appears anywhere in B2.

Why does IF say a number stored as text is bigger than my target?

When Sheets compares text with a number, the text always ranks higher. Re-enter imported values as numbers, or wrap the cell in VALUE, as in =IF(VALUE(D2)>=C2, "Hit", "Missed").

Did this answer your question?

One click, no account needed.

Still need help?

Our support team can take it from here.

Jump to