IF(logical_expression, value_if_true, value_if_false) checks a test and returns one of two results. =IF(C2>=1000, "Large", "Small") labels each invoice by size.
The test is any comparison: =, <> (not equal), >, <, >=, <=. Text goes in double quotes and is matched without regard to case. The results can be text, numbers, other cells, or a calculation: =IF(D2="Paid", 0, C2) shows what is still owed.
Two cases trip people up:
- Blank cells. Test for an empty cell with
="": =IF(E2="", "Unpaid", "Paid"). An empty cell also equals 0 in a number test, so =IF(F2>0, ...) treats blanks as 0.
- Numbers typed as text. "1000" in quotes is text; leave numbers bare in a test.
IFs can be nested, =IF(A, x, IF(B, y, z)), but when you need more than two or three, IFS in the next lesson reads more easily.