Logical
All versions
◉ 58 views
=IF()
How to use the IF function in Excel to make logical comparisons between data values.
Applies To:
Excel for Microsoft 365Excel for Microsoft 365 for MacExcel 2024Excel 2024 for MacExcel 2021Excel 2021 for MacExcel 2019Excel 2016
=IF(logical_test, value_if_true, [value_if_false])
Hover argument names in the table for details.
Output typeMixed
Popularity95 / 100
VolatileNo
Dynamic ArrayNo
Download sample .xlsx ▦ Try in Playground
Dedicated file for this function — safe & lightweight · sample data + live formulas
⬇ Download Sample Workbook
A dedicated .xlsx for =IF() with Persian sample data & live formulas — open in Excel and practice.
- Sheet “Sample” — data table + formula in place
- Sheet “Guide” — syntax, arguments & tips from this page
- Instant & secure (token + rate limit)
Quiz this function
%d questions — syntax, example & errors — test yourself!
◧ Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
logical_test |
Any type | Required | The condition you want to test. |
value_if_true |
Any type | Required | The value that you want returned if the result of logical_test is TRUE. |
value_if_false |
Any type | Optional | The value that you want returned if the result of logical_test is FALSE. |
▣ Examples
Example 1
=IF(C2=”Yes”,1,2)
Example 2
=IF(C2=1,”Yes”,”No”)
Example 3
=IF(C2>B2,”Over Budget”,”Within Budget”)
Example 4
=IF(C2>B2,C2-B2,0)
Example 5
=IF(E7=”Yes”,F5*0.0825,0)
✦ Tips
- 0 (zero) in cell: There was no argument for either value_if_true or value_if_False arguments. To see the right value returned, add argument text to the two arguments, or add TRUE or FALSE to the argument.
- #NAME? in cell: This usually means that the formula is misspelled.
💬 Comments & Q&A 0 approved
🔒 Your comment will be published after review.Share your thoughts — visible after admin approval
No comments yet — be the first!