Sub topic 4
Returning text, numbers, or nothing
An IF formula returns whatever you put in its second and third arguments. This chapter covers what those arguments can hold, how Sheets treats each type of result, and the errors that appear when the types are mixed up.
This chapter assumes you can already write =IF(test, value_if_true, value_if_false) and that you know how comparison operators such as >= produce TRUE or FALSE. It also assumes you are comfortable with cell references such as B2.
What an IF formula can return
The second and third arguments of IF are ordinary expressions. Each one can be any of the following:
| Kind of result | Example argument | What the cell shows |
|---|---|---|
| Text | `"Pass"` | Pass |
| Number | `100` | 100 |
| Calculation | `B2*0.1` | The computed number |
| Cell reference | `C2` | The current value of C2 |
| Boolean | `TRUE` | TRUE |
| Empty string | `""` | Looks blank |
| Another function | `IF(...)` or `SUM(...)` | That function's result |
Only one branch is used per row. Sheets evaluates the test, then returns the value from the matching branch.
Returning text
Text must be wrapped in straight double quotes. Without quotes, Sheets reads the word as a name, and the formula fails.
=IF(A2="Paid", "Done", "Follow up")Here A2 is a cell reference, so it has no quotes. "Paid", "Done" and "Follow up" are text literals, so they do.
Three points about text results:
- Text comparison with
=is not case-sensitive."paid","PAID"and"Paid"all match. - Spaces count. A cell containing
"Paid "with a trailing space does not equal"Paid". If a comparison fails for no visible reason, check for stray spaces. - Curly quotes (
“ ”) pasted from a document or a web page are not valid. Sheets reports a parse error. Retype them as straight quotes.
Returning numbers
Numbers are written without quotes. A number in quotes is text, and that difference matters later when you do arithmetic on the results.
=IF(B2>=100, 0.1, 0)This returns a 10% discount rate for orders of 100 or more, and 0 otherwise. A number result can be formatted like any other number, for example as a percentage, from the Format menu.
You can also return a calculation. This formula applies the discount directly:
=IF(B2>=100, B2*0.9, B2)Each branch can be a different calculation. The branches don't need the same shape.
Numbers stored as text
A common cause of surprising results is a "number" that Sheets stores as text. Text values align left by default, and numbers align right. If B2 holds the text "75", a comparison such as B2>=50 can give a result you don't expect. Fix the source data, for example by re-entering the value or converting the column with Format > Number, instead of adding workarounds to the formula.
Why quotes change the result
The difference between "100" and 100 shows up when you use the results.
=IF(B2>=100, "100", "0")This formula returns the text "100" or "0". The result looks like a number, but SUM ignores text values, and + may or may not convert them depending on context. If you plan to total the column, return real numbers:
=IF(B2>=100, 100, 0)Mixing types in a single column also makes later work harder. Pick one type per output column when you can. If a column is a status label, return text in both branches. If it is an amount, return numbers in both.
Returning nothing
There are three ways to produce "nothing", and they behave differently.
Leaving out the third argument
If you omit value_if_false, Sheets returns FALSE when the test fails.
=IF(B2>=50, "Pass")For a failing row, the cell shows FALSE, not a blank. This is rarely what you want in a report. Always decide what the false branch should show.
Leaving the argument empty
If you include the comma but leave the argument empty, the behavior differs again:
=IF(B2>=50, "Pass", )In Google Sheets, an empty argument is treated as 0 when the result is used in a formula, and the cell displays a 0 or a blank depending on the context. Because the outcome is hard to predict, avoid this form. Write the intent explicitly instead.
Returning an empty string
The reliable way to show nothing is "", which is a text value with zero characters.
=IF(B2>=50, "Pass", "")Passing rows show Pass. Failing rows look blank. The cell is not truly empty, though. It contains a formula that returns an empty string.
Empty string versus truly empty
An empty cell and a cell holding "" look the same on screen but are not the same thing.
| Check | Truly empty cell | Cell containing `""` |
|---|---|---|
| `=A2=""` | TRUE | TRUE |
| `=ISBLANK(A2)` | TRUE | FALSE |
| `=COUNTA(A2)` | 0 | 1 |
| `=LEN(A2)` | 0 | 0 |
The practical effects:
COUNTAover a column counts cells that contain"". A column of IF results with many blanks gives a count higher than the number of visible entries.ISBLANKreturns FALSE for a formula that returns"". To test both cases with one check, useA2="", which is TRUE for both.- Charts and some functions treat an empty string as text, not as a gap. A chart may plot it as zero or show an error.
The same issue affects arithmetic. This formula fails if C2 holds "":
=C2*2Sheets returns a #VALUE! error because it cannot multiply an empty string. A truly empty cell would be treated as 0 and give 0. If another formula must read your IF results as numbers, return 0 or handle the text case, rather than returning "".
Combining text and numbers in one result
Sometimes you want a sentence that includes a number. Join pieces with the & operator.
=IF(B2>=50, "Passed with " & B2 & " points", "Failed with " & B2 & " points")The & operator converts the number to text and joins the parts. The result is a text value, so you cannot sum it afterward.
To control number formatting inside the text, use TEXT:
=IF(B2>=100, "Discount: " & TEXT(0.1, "0%"), "No discount")This returns Discount: 10%. Without TEXT, the number would appear as 0.1.
Returning cell references and other functions
Either branch can point at another cell, so the formula picks which value to display.
=IF(A2="Member", C2, D2)If A2 is Member, the cell shows the value in C2. Otherwise it shows D2. This is a common pattern for price lists where member and standard prices sit in separate columns.
Branches can also contain functions:
=IF(B2>=50, SUM(C2:E2), AVERAGE(C2:E2))Sheets evaluates only the branch that is selected. That means an error in the unused branch does not break the result. For example, =IF(C2=0, 0, B2/C2) is safe, because the division is never evaluated when C2 is 0.
Returning TRUE and FALSE
You can return Boolean values directly. These are not text, so they have no quotes.
=IF(B2>=50, TRUE, FALSE)This formula is redundant. The comparison already returns TRUE or FALSE, so =B2>=50 gives the same result. Use IF when you want to return something other than a Boolean.
How the result type flows through the formula
The diagram shows what happens for each row.
A worked example
Suppose a sheet tracks orders:
| Row | A | B | C |
|---|---|---|---|
| 1 | Customer | Total | Note |
| 2 | Ada | 120 | |
| 3 | Ben | 80 | |
| 4 |
You want column C to show a discount amount for totals of 100 or more, and nothing otherwise. Enter this in C2 and copy it down:
=IF(B2>=100, B2*0.1, "")Results:
- Row 2 returns
12, a number. - Row 3 returns
"", which looks blank. - Row 4 returns
""becauseB4is empty and an empty cell is not greater than or equal to 100.
Now suppose a later formula totals column C with =SUM(C2:C4). SUM ignores the text values, so it returns 12 and no error appears. But =C2+C3 would return #VALUE!. If you need to do row-by-row arithmetic on column C, return 0 in the false branch and use number formatting to hide zeros if needed.
Common mistakes with return values
- Missing quotes around text.
=IF(A2="Paid", Done, "Follow up")fails becauseDoneis read as a name. Add quotes. - Quotes around numbers.
"0"is text and will not sum. - Mixed types in one column. A column that holds numbers in some rows and text in others makes sorting, charts and totals unreliable.
- Expecting a blank from a missing argument. The two-argument form returns FALSE, not a blank.
- Treating
""as empty.ISBLANKandCOUNTAdisagree with what you see.
Summary of when to return what
| Goal | Return | Example |
|---|---|---|
| A label | Text in quotes | `"Pass"` |
| A value you will total | A number | `100` or `B2*0.1` |
| A visual blank in a label column | Empty string | `""` |
| A visual blank in a numeric column | `0` with hidden-zero format | `0` |
| A sentence with a value in it | Text joined with `&` | `"Total: " & B2` |
Exercise
Column B holds scores. You enter =IF(B2>=50, "Pass") in C2 and copy it down. Rows that fail show FALSE. Rewrite the formula so failing rows look blank, and explain why =ISBLANK(C2) will still return FALSE for those rows.
Show answer
Use =IF(B2>=50, "Pass", ""). The third argument is now an empty string, so failing rows look blank. ISBLANK returns FALSE because C2 contains a formula, and a formula that returns "" is not a truly empty cell. To test for both cases, use =C2="".
Exercise
A formula in D2 is =IF(B2>=100, "10", "0"). A colleague sums column D with =SUM(D2:D20) and gets 0. What is wrong, and what is the fix?
Show answer
The branches return text because the numbers are in quotes. SUM ignores text values. Remove the quotes: =IF(B2>=100, 10, 0).
Exercise
What does =IF(C2=0, 0, B2/C2) return when C2 is 0, and why does it not produce a divide-by-zero error?
Show answer
It returns 0. Sheets evaluates only the branch selected by the test. When C2 is 0, the test is TRUE, so only the value 0 is returned and B2/C2 is never calculated.