IF Function (LibreOffice Calc)
The IF function in LibreOffice Calc evaluates a condition and returns one value if the condition is TRUE and another value if it is FALSE. Learn syntax, examples, common errors, and best practices.
Verification status: Consult the documentation, examples and any stated test scope below. How formula examples are checked
Availability and version history
- Introduced: Documented by LibreOffice 26.8.1.1; original introduction not established.
- Availability: Supported in LibreOffice 26.8.1.1, verified against its function registry. This identifies a supported release, not a final working version.
- Scope: Desktop Calc, using the English function name. Availability in other spreadsheet applications is separate.
- Checked: 2026-10-14 — function reference; versioned support. Documentation/source check; not a new native test. Existing example-specific test claims below retain their stated scope.
Native-tested visual example: Inventory reorder decision
Quick answer: Display a plain-language status from a stock threshold. The following example was run in LibreOffice Calc 25.2.3.2, not simulated or inferred from a formula description.
Enter the sample data
The downloadable workbook uses these exact rows on its Example sheet. Enter the values or download the editable IF ODS practice workbook instead.
| Sheet row | A: SKU | B: Product | C: Stock | D: Supplier |
|---|---|---|---|---|
| 5 | SKU-01 | Pens | 15 | North |
| 6 | SKU-02 | Folders | 25 | East |
| 7 | SKU-03 | Pads | 12 | West |
| 8 | SKU-04 | Mouse | 5 | North |
| 9 | SKU-05 | Cable | 11 | East |
| 10 | SKU-06 | Pencil | 20 | West |
Formula and result
Select E5 in the practice workbook. The formula is:
=IF(C8<10;"Reorder";"Stock OK")
Verified output: Reorder. C8 contains 5; because 5 is less than 10, IF returns its first text result.

Screenshot captured from LibreOffice Calc 25.2.3.2. The formula, input values and E5 result are visible in the actual application.
Second example you can try
The workbook also includes this independently tested variation in E12:
=IF(C5<10;"Reorder";"Stock OK")
Verified output: Stock OK. Change the related input cell and press Enter to see the result update.
Common mistake: Use quotation marks around literal text, but not around a numeric comparison.
Official documentation: LibreOffice Calc reference for IF. Test scope: These two worked examples were recalculated in Calc 25.2.3.2; other historical formulas elsewhere on this page may still require separate testing. This file includes no generated or artificial application screenshot.
What the IF Function Does
- Evaluates a logical condition
- Returns one value when the condition is TRUE
- Returns another value when the condition is FALSE
- Works with numbers, text, dates, and formulas
- Can be nested to handle multiple conditions
- Combines with AND, OR, and NOT for complex logic
- Integrates with error-handling functions like IFERROR and IFNA
It is designed to be flexible, readable, and compatible across major spreadsheet applications.
Syntax
IF(test; value_if_true; value_if_false)
;) to separate arguments, not commas.
Arguments
-
test:
A logical expression that evaluates to TRUE or FALSE (for example,A1 > 10,B2 = "Yes",C3 <> 0). -
value_if_true:
The value, text, or formula returned whentestevaluates to TRUE. -
value_if_false:
The value, text, or formula returned whentestevaluates to FALSE.
Err:508 or Err:509.
Basic Examples
Return text based on a numeric condition
=IF(A1 > 50; "Pass"; "Fail")
Return numbers based on a text condition
=IF(B2 = "Yes"; 1; 0)
Use IF with cell references and arithmetic
=IF(C5 <= D5; D5 - C5; 0)
Use IF with text comparisons
=IF(E1 = "North"; "Region A"; "Region B")
Advanced Examples
Nested IF statements (multi-level grading)
=IF(A1 >= 90; "A"; IF(A1 >= 80; "B"; IF(A1 >= 70; "C"; IF(A1 >= 60; "D"; "F"))))
IF with AND (multiple conditions must be TRUE)
=IF(AND(A1 >= 18; B1 = "Yes"); "Eligible"; "Not Eligible")
IF with OR (at least one condition must be TRUE)
=IF(OR(C1 = "Gold"; C1 = "Platinum"); "Priority"; "Standard")
IF with calculations (tiered discount)
=IF(A1 > 1000; A1 * 0.10; A1 * 0.05)
IF to check for blanks
=IF(A1 = ""; "Missing"; "OK")
IF with error handling using IFERROR
=IFERROR(A1 / B1; "Division Error")
IF with concatenated text output
=IF(A1 > 0; "Profit: " & A1; "Loss: " & A1)
Combining IF with Other Functions
IF with SUM and AVERAGE
=IF(AVERAGE(A1:A10) > 50; SUM(B1:B10); 0)
IF with COUNTIF (conditional messages)
=IF(COUNTIF(A1:A100; ">100") > 0; "Values over 100 found"; "All values ≤ 100")
IF with DATE comparisons
=IF(A1 < TODAY(); "Past"; "Today or Future")
Common Errors and Fixes
Err:508 — Missing parenthesis
Usually caused by:
- A missing closing
)in nested IF formulas - Copying formulas that use commas instead of semicolons
Err:509 — Missing operator
Occurs when:
- A comparison operator is missing
- A nested IF is broken by missing separators or operators
IF returns the wrong branch
Possible causes:
- Numbers stored as text
- Text values with trailing spaces
- Incorrect comparison operators
IF always returns FALSE
Often caused by:
- Comparing text to numbers
- Hidden characters in text cells
- Using the wrong operator
Best Practices
- Keep logical tests simple and readable
- Use AND and OR to avoid deeply nested IFs
- Use helper columns for complex logic
- Wrap risky expressions with IFERROR or IFNA
- Document complex logic with comments or notes
Reproducible example (tested in LibreOffice Calc)
This standalone example was calculated in LibreOffice Calc 25.2.3.2 and matched the expected value. It is a practical cross-check of one usage, not proof that every example elsewhere on this page is correct.
=IF(2>1;"Yes";"No")
Expected result: Yes.
Return a different value for TRUE and FALSE outcomes.
If the result differs, check the referenced cells, argument separators and number formatting. For more information, consult the LibreOffice Calc official help.