Perform logical tests and return different values based on whether a condition is TRUE or FALSE.
Scenario | Formula | Result |
---|---|---|
Check if a number is greater than 50 | =IF(40>50, "Pass", "Fail") | Pass |
Check if a cell is empty | =IF(A1="", "Empty", "Not Empty") | If A1 is blank, Result: "Empty" |
Check if a number is even or odd | =IF(MOD(A1,2)=0, "Even", "Odd") | If A1 = 10, Result: "Even" |
Check if a person is eligible to vote (age 18+) | =IF(A1>=18, "Eligible", "Not Eligible") | If A1 = 20, Result: "Eligible" |
Check if a value is "Yes" or "No" | =IF(A1="Yes", "Approved", "Rejected") | If A1 = "Yes", Result: "Approved" |
Check if a date is in the past, present, or future (Multiple IF functions) | =IF(A1< TODAY(), "Past", IF(A1=TODAY(), "Today", "Future")) | If A1 = 10-Feb-2025, Result: "Past" |