← All how-to recipes

How to write nested IF statements

✓ Verified in LibreOffice 25.8.7.3

Chain several IF tests for multi-way decisions — grades, tiers, status labels.

The formula

AppFormulaNotes
Excel=IF(A2>=90,"A",IF(A2>=80,"B",IF(A2>=70,"C","F")))Each IF's 'else' slot holds the next IF. On Excel 2019+/Sheets, IFS is the flatter alternative.
Google Sheets=IF(A2>=90,"A",IF(A2>=80,"B",IF(A2>=70,"C","F")))Identical.
LibreOffice Calc=IF(A2>=90,"A",IF(A2>=80,"B",IF(A2>=70,"C","F")))Identical.

How it works

A nested IF puts the next IF where the previous one's "value if false" goes, so the tests run in order until one is true: 85 fails >=90, passes >=80, so it stops at "B". Order matters — arrange tests from most to least restrictive, or an early loose test grabs everything. The last IF's false-slot is your catch-all ("F" here). Beyond ~3-4 levels nesting gets unreadable and error-prone; switch to IFS (=IFS(A2>=90,"A",A2>=80,"B",...,TRUE,"F")) or a lookup table with the closest-match pattern, both easier to maintain.

Verified, not just documented

We ran =IF(A2>=90,"A",IF(A2>=80,"B",IF(A2>=70,"C","F"))) in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned B — exactly the expected result. Every formula here is confirmed by actually executing it.