How to Use the IF Function In Excel

The IF function tests a condition and returns one result when it is TRUE and another when it is FALSE. Use it to label values, calculate different results, or check whether a record meets a rule.

Simple IF Functionality

An IF formula has a logical test, a result for TRUE, and an optional result for FALSE. Start the formula with an equals sign when you enter it in a worksheet cell:

IF(logical_test, value_if_true, [value_if_false])

The first argument in the function is the logical test, which can be any expression that results in a true or false value. The second argument is the value that will be returned if the logical test is true, and the third argument is the value that will be returned if the logical test is false.

For example, suppose you want to label amounts of 300 or more as “High” and amounts below 300 as “Low”. With a numeric amount in B2, use:

=IF(B2>=300, “High”, “Low”)

The test B2>=300 checks whether B2 is greater than or equal to 300. If it is, IF returns “High“; otherwise, it returns “Low“. Exactly 300 returns High because the test includes equality.

Enter a number in B2, select C2, type =IF(B2>=300,"High","Low"), and press Enter. To label more rows, fill the formula down from C2. The relative reference B2 becomes B3, B4, and so on.

Three IF arguments: B2 greater than or equal to 300 is the test; High is the TRUE result; Low is the FALSE result.
Each argument has a separate job in the formula.

Text results such as “High” need double quotation marks; numbers and cell references do not. For example, =IF(B2>=300,1,0) returns a number. Use "" for a result that displays no text: =IF(B2>=300,"High",""). Explicitly supply the FALSE result when you want a particular label, number, or empty string.

IF decision flow: B2 of 300 or more returns High; a number below 300 returns Low. Exactly 300 follows the TRUE branch.
The greater-than-or-equal test includes the cutoff value.
Value in B2Is B2 >= 300?Result
299FALSELow
300TRUEHigh
350TRUEHigh
Check the boundary as well as values above and below it.

These examples use commas between arguments. If your Excel regional settings use semicolons, enter =IF(B2>=300;"High";"Low") instead.

Advanced IF Functionality: Using AND and OR Criteria

You can also use the IF function in Excel by combining it with the AND and OR functions. AND returns TRUE only when all its conditions are true. OR returns TRUE when at least one condition is true. IF uses that TRUE or FALSE result to choose what to return.

Using the AND Function

The AND function allows you to check multiple conditions at the same time. For example, suppose you have a list of students and their math and English marks, and you want to find out which students have passed the class by getting at least 40 marks in both subjects. To do this, you would use the AND function in the logical test of the IF function, like so:

=IF(AND(C12>=40, D12>=40), “Pass”, “Fail”)

This logical test checks if the value in cells C12 and D12 is greater than or equal to 40, using the AND function. If both conditions are true, the function will return “Pass“. Otherwise, it will produce a “Fail“.

Using the OR Function

The OR function allows you to check if at least one of several conditions is true. For example, suppose you want to find out which students have passed the class by getting at least 40 marks in either math or English. To do this, you would use the OR function in the logical test of the IF function, like so:

=IF(OR(C12>=40, D12>=40), “Pass”, “Fail”)

This logical test checks if the value in cells C12 and D12 is greater than or equal to 40 using the OR function. If at least one of the conditions is true, the function will return “Pass“; otherwise, it will return “Fail“.

With a 40-mark threshold, 45 and 50 pass both AND and OR; 45 and 35 fail AND but pass OR; 35 and 35 fail both.
The same marks can give different results under AND and OR.
Math marksEnglish marksIF with ANDIF with OR
4550PassPass
4535FailPass
3535FailFail
AND requires both subjects to reach 40; OR requires either subject to reach 40.

Conclusion

Choose a logical test that matches your rule, then supply the two results you want. Check a value at the cutoff before filling the formula down. For multiple conditions, use AND when every condition must be true and OR when any one condition is enough. The video tutorial also covers nested IF formulas.