Skip to main content

How to use IF function with AND, OR, and NOT in Excel?

Excel's IF function is a testament to the power and versatility of logical operations in data handling. The essence of the IF function is its ability to evaluate conditions and return specific outcomes based on those evaluations. It operates on a fundamental logic:

=IF(condition, value_if_true, value_if_false)

When combined with logical operators like AND, OR, and NOT, the IF function's capabilities significantly expand. The power of the combination lies in their ability to process multiple conditions simultaneously, providing results that can adapt to varied and complex scenarios. In this tutorial, we will explore how to effectively leverage these powerful functions in Excel to unlock new dimensions of data analysis and enhance your decision-making process. Let's dive in and discover the practical applications of these formidable Excel functions!

Nested IF AND OR NOT formula


IF AND formula

To assess multiple conditions and deliver a specific result when all conditions are met (TRUE), and a different result when any condition isn't met (FALSE), you can incorporate the AND function within the logical test of the IF statement. The structure for this is:

=IF(AND(condition1, condition2, …), value_if_all_true, value_if_any_false)

For instance, imagine you're a teacher analyzing student grades. You want to determine if a student passes based on two criteria: a score above 70 AND attendance over 80%.

  1. Start by examining the first student's data, with their score in cell B2 and attendance in cell C2. For this student, apply the below formula in D2:
    =IF(AND(B2>70, C2>80%), "Pass", "Fail")
    Tip: This formula checks if the score in B2 is above 70 and attendance in C2 is over 80%. If both conditions are met, it returns "Pass"; otherwise, it returns "Fail".
  2. Drag the formula down through the column to evaluate each student’s score and attendance.

    IF AND formula


IF OR Formula

To evaluate multiple conditions and return a specific result when any one of the conditions is met (TRUE), and a different result when none of the conditions are satisfied (FALSE), the OR function can be used within the logical test of the IF statement. The formula is structured as follows:

=IF(OR(condition1, condition2, …), value_if_any_true, value_if_all_false)

For example, in an educational context, consider a more flexible criterion for student passing. Here, a student is deemed to pass if they either score above 90 OR have an attendance rate higher than 95%.

  1. Begin by evaluating the first student's performance, with their score in cell B2 and attendance in cell C2. Apply the formula in an adjacent cell, such as D2, to assess:
    =IF(OR(B2>90, C2>95%), "Pass", "Fail")
    Tip: This formula evaluates if the student either scores above 90 in B2 or has an attendance rate over 95% in C2. If either condition is met, it returns "Pass"; if not, "Fail".
  2. Copy this formula down the column to apply it for each student in your list, enabling a quick assessment of each student’s eligibility for passing based on these criteria.

    IF OR formula


IF NOT Formula

To evaluate a condition and return a specific result if the condition is NOT met (FALSE), and a different result if the condition is met (TRUE), the NOT function within the IF statement is your solution. The structure for this formula is:

=IF(NOT(condition), value_if_false, value_if_true)

For a practical example, consider a workplace scenario where employee bonuses are determined based on their attendance record. Employees are eligible for a bonus if they have NOT been absent for more than 3 days.

  1. To evaluate this for the first employee, whose days absent are in cell B2, use the formula:
    =IF(NOT(B2>3), "Eligible", "Not Eligible")
    Tip: This formula checks the number of days absent in B2. If it's NOT more than 3, it returns "Eligible"; otherwise, "Not Eligible".
  2. Copy this formula down the column to apply it for each employee.

    IF NOT formula


Advanced scenarios with IF and logical functions

In this section, we will explore the intricate use of Excel's IF function with logical operators like AND, OR, and NOT. This section covers everything from case-sensitive evaluations to nested IF statements, showcasing Excel's versatility in complex data analysis.


If your condition is met, then calculate

In addition to providing predefined outcomes, the Excel IF function, when combined with logical operators like AND, OR, and NOT, can execute various calculations based on whether the set conditions are true or false. Here, we'll use the IF AND combination as an example to showcase this functionality.

Imagine you're managing a sales team and want to calculate bonuses. You decide that an employee receives a 10% bonus on their sales if they exceed $100 in sales AND have worked more than 30 hours in a week.

  1. For the initial assessment, look at Alice’s data with her sales in cell B2 and hours worked in cell C2. Apply this formula in D2:
    =IF(AND(B2>100, C2>30), B2*0.1, 0)
    Tip: This formula calculates a 10% bonus on Alice’s sales if her sales exceed $100 and her hours worked are over 30. If both conditions are met, it calculates the bonus; otherwise, it returns 0.
  2. Extend this formula to the rest of your team by copying it down the column. This approach ensures each employee’s bonus is calculated based on the same criteria.

    IF Then calculate

Note: In this section, we focus on using the IF function with AND for calculations based on specific conditions. This concept can also be extended to include OR and NOT, as well as nested logical functions, allowing for a variety of conditional calculations in Excel.


Case-sensitive AND, OR and NOT statements

In Excel, while logical functions like AND, OR, and NOT are typically case-insensitive, there are scenarios where case sensitivity in text data is crucial. By integrating the EXACT function with these logical operators, you can effectively handle such case-sensitive conditions. In this section, we demonstrate the use of the IF and OR functions with a case-sensitive approach as an example.

Imagine a retail scenario where a product is eligible for promotion if it either exceeds $100 in sales OR its code exactly matches "ABC" in a case-sensitive check.

  1. For the first product listed in row 2, with its sales in cell B2 and product code in cell C2, use this formula in D2:
    =IF(OR(B2>100, EXACT(C2,"ABC")), "Promotion Eligible", "Not Eligible")
    Tip: This formula evaluates if the sales figure in B2 exceeds $100 or the product code in C2 is exactly "ABC". Meeting either of these conditions renders the product eligible for promotion; failing both makes it ineligible.
  2. Replicate this formula across the column for all products to uniformly assess their eligibility for promotion based on sales and case-sensitive product code criteria.

    Case-sensitive IF OR formula

Note: In this section, we've illustrated the use of the IF and OR functions with the EXACT function for case-sensitive evaluations. You can similarly apply the EXACT function in your IF formulas combined with AND, OR, NOT, or nested logical functions to meet diverse case-sensitive requirements in Excel.


Integrating IF with nested AND, OR, NOT statements

Excel's IF function, when nested with AND, OR, and NOT, offers a streamlined approach to handle more layered conditions. This section provides an example showcasing the application of these nested functions in a retail setting.

Suppose you're overseeing a team responsible for various product categories, and you want to determine their bonus eligibility. An employee is eligible for a bonus if they: achieve sales over $100, AND either work more than 30 hours a week OR are NOT in the Electronics department.

  1. First, assess Anne's performance, with her sales in cell B2, hours worked in cell C2, and department in cell D2. The formula in E2 would be:
    =IF(AND(B2>100, OR(C2>30, NOT(D2="Electronics"))), "Eligible", "Not Eligible")
    Tip: This formula checks if Anne has sales exceeding $100 and either works more than 30 hours or is not working with Electronics. If she meets these criteria, she is deemed "Eligible"; if not, "Not Eligible".
  2. Copy this formula down the column for each employee to uniformly assess bonus eligibility, considering their sales, hours worked, and department.

    Nested IF AND OR NOT formula


Nested IF functions with AND, OR, NOT

When your data analysis involves multiple conditional checks, nested IF functions in Excel offer a powerful solution. This method entails constructing separate IF statements for distinct conditions, including AND, OR, and NOT logic, and then integrating them into one streamlined formula.

Consider a workplace where employee performance is rated as "Excellent", "Good", or "Fair" based on sales, hours worked, and policy adherence:

  • "Excellent" for sales over $150 AND more than 35 hours worked.
  • Otherwise, "Good" for sales above $100 OR policy violation NOT more than 1.
  • "Fair" if neither of these conditions is met.

To assess each employee's performance according to the above conditions, please do as follows:

  1. Begin with Anne's evaluation, whose sales are in cell B2, hours worked in cell C2, and policy violations in cell D2. The nested IF formula in E2 is:
    =IF(AND(B2>150, C2>35), "Excellent", IF(OR(B2>100, NOT(D2>1)), "Good", "Fair"))
    Tip: This formula first checks if Anne's sales and hours meet the criteria for "Excellent". If not, it evaluates whether she qualifies for "Good". If neither condition is met, she is categorized as "Fair".
  2. Extend this nested IF formula to each employee to consistently assess their performance across multiple criteria.

    Nested IF Functions


Using IF with AND OR NOT: Frequently asked questions

This section aims to address frequently asked questions for using IF with AND, OR, and NOT in Microsoft Excel.

How many conditions can the AND, OR and NOT functions support?
  • The AND and OR functions can support up to 255 individual conditions. However, it's advisable to use only a few to avoid overly complex formulas that are hard to maintain.
  • The NOT function only takes one condition.
Can I use operators like <, >, = in these functions?

Certainly, in Excel's AND, OR, and NOT functions, you can utilize operators like less than (<), greater than (>), equals (=), greater than or equal to (>=), and more to establish conditions.

Why does a #VALUE error occur in these functions?

A #VALUE error in Excel's AND, OR, and NOT functions often arises if the formula doesn't meet any specified condition or if there's a problem with how the formula is structured. It indicates that Excel is unable to interpret the input or the conditions within the formula correctly.


Above is all the relevant content related to using IF with AND, OR and NOT functions in Excel. I hope you find the tutorial helpful. If you're looking to explore more Excel tips and tricks, please click here to access our extensive collection of over thousands of tutorials.

Comments (72)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hey Friends,

Donno if this Forum works now:

I am trying to figure out a formula for the following:
I have 3 Columns : viz : A1,D1, L1 with text contents. And output expected in M1

So if any of the cells A,D,L has Faulty mentioned, then M1 should result "Faulty", Else if all 3 are blank , need "Spare", and if any cell has any data then it shoud show "Mapped"
This comment was minimized by the moderator on the site
Kan iemand mij helpen met onderstaande voor het maken van een formule?
als B2 de tekst factuur staat moet in cel D8 de tekst factuurdatum komen te staan. Als in cel B2 de tekst offerte staat moet in cel D8 offertedatum komen te staan.

Alvast hartelijk dank
This comment was minimized by the moderator on the site
Hi there,

Can you show us the look of the text invoice, text quotation and text quotation date?
This comment was minimized by the moderator on the site
I am trying to write a formula to populate scores based off a range of values. This is what I have so far:

=IF(C2>=104.5%,"5", IF(C2<=104.49%,"4", IF(C2>=95.5%,"4", IF(C2<=95.49%,"3", IF(C2>=79.5%,"3", IF(C2<=79.49%,"2", IF(C2>=59.5%,"2", IF(C2<=59.49%,"1"""))))))))

The formula is working and I am not receiving any error messages. However, it is not populating the lower range values correctly. Here is my range:

>105% = 5
96%-105% = 4
80%-95% = 3
60%-79% = 2
<60% = 1

Any help is greatly appreciated.
This comment was minimized by the moderator on the site
Hi there,

I've fixed the formula as shown below:
=IF(C2>105%,"5",IF(C2>=96%,"4",IF(C2>=80%,"3",IF(C2>=60%,"2","1"))))

Hope this is what you want.

Amanda
This comment was minimized by the moderator on the site
Never mind, I figured it out. Thanks!
This comment was minimized by the moderator on the site
Kan iemand mij helpen aan onderstaande formule?
Alvast bedankt!

als Q groter is dan C dan Q en als Q kleiner is dan H dan H tenzij H 0 is dan is Q
This comment was minimized by the moderator on the site
Hi there,

Suppose, Q=A1, C=A2, H=A3. Please use the formula below: =IF(B1>B2,B1,IF(B1<B3,IF(B3=0,B1,B3),B3))

Hope this is what you want.

Amanda
This comment was minimized by the moderator on the site
I am trying to find a formula when realignment is in column A then add the text conflict when transition begins date (B) is >= the solution start date in column D OR if activation in column A then add the text conflict when transition begins date is <= solution start date in column D OR if deactivation then add the text conflict when transition begins date is >= the solution start date
A B C D E
Transition Type Transition Begins Transition Ends Solution Start Date Solution End Date
Realignment 11/1/2022 11/15/2022 1/15/2022 3/6/2022
Realignment 11/1/2022 11/15/2022 1/15/2022 3/16/2022
Realignment 11/1/2022 11/15/2022 6/1/2022 7/16/2022
Realignment 11/1/2022 11/15/2022 6/1/2022 7/16/2022
Realignment 11/1/2022 11/15/2022 6/1/2022 7/16/2022
Activation 1/1/2022 1/31/2022 1/15/2022 3/6/2022
Deactivation 12/1/2021 12/15/2021 1/15/2022 3/6/2022
Reorganization 2/6/2022 2/12/2022 1/15/2022 3/6/2022
Activation 12/1/2021 12/31/2021 11/1/2029 12/31/2029
Activation 12/1/2021 12/31/2021 2/1/2025 7/31/2025
Activation 12/1/2021 12/31/2021 4/1/2024 6/29/2024
Activation 12/1/2021 12/31/2021 2/1/2028 3/2/2028
Activation 12/1/2021 12/31/2021 2/1/2022 5/20/2025
Activation 12/1/2021 12/31/2021 9/6/2022 3/16/2023
Activation 12/1/2021 12/31/2021 6/1/2024 11/28/2024
Activation 12/1/2021 12/31/2021 9/1/2022 9/7/2022
Deactivation 10/1/2021 10/30/2021 11/1/2029 12/31/2029
Deactivation 10/1/2021 10/30/2021 2/1/2025 7/31/2025
Deactivation 10/1/2021 10/30/2021 4/1/2024 6/29/2024
Deactivation 10/1/2021 10/30/2021 2/1/2028 3/2/2028
Deactivation 10/1/2021 10/30/2021 2/1/2022 5/20/2025
Deactivation 10/1/2021 10/30/2021 9/6/2022 3/16/2023
Deactivation 10/1/2021 10/30/2021 6/1/2024 11/28/2024
Deactivation 10/1/2021 10/30/2021 9/1/2022 9/7/2022
Reorganization 2/1/2022 2/28/2022 11/1/2029 12/31/2029
Reorganization 2/1/2022 2/28/2022 2/1/2025 7/31/2025
This comment was minimized by the moderator on the site
Hi there,

What do you mean by adding the text conflict? Can you show me the result you want?

Amanda
This comment was minimized by the moderator on the site
=IF(AND(AY7>60,AY7>30),"0.02","0.04"),if(and(ay7<=30,ay<az),"0.06"),if(and(ay7<=15,ay<az),"0.08")
This comment was minimized by the moderator on the site
I am trying use If formula for one oridinary file, lets say I have number from 1 to 31 in a perticular cell. I need to show the result in another cell as if number in that perticular cell is less than 26 they it will zero, if the number in that perticular cell is from 26 to 30 then it will show the same number but if the number is abobe 30 then it will show the 30 only....Can anyone advise me how can I formulate this formula?
This comment was minimized by the moderator on the site
Hi there,

Please try the formula below: =IF(A1<26,0,IF(A1<=30,A1,30))

Hope this could help you.

Amanda
This comment was minimized by the moderator on the site
Ciao,
mi potete aiutare perfavore...
ho tre celle:
1-data di pagamento
2-totale
3-totale se pagato

vorrei che quando inserisco la data di pagamento(1), la casella 3(che è vuota) si riempisse automaticamente come la casella 2
come posso fare?
This comment was minimized by the moderator on the site
Hi there,

Do you want to fill the value of the cell 2 in the cell 3?
If so, you can enter this IF formula in the casella 3: =IF(casella 1<>"",casella 2,"")

Amanda
This comment was minimized by the moderator on the site
=IF(D4<=30000, and =>20000,than D4a-5000,and if(d4<=40000, and >30000, than d4-6000) convert into formula
This comment was minimized by the moderator on the site
Try the formula. Since I don't quite understand you, please check and change the part "DA4-5000" and "D4-6000", "FALSE" to the results you want.
=IF(AND(D4<=30000,D4>20000),"DA4-5000",IF(AND(D4<=40000,D4>30000),"D4-6000","FALSE"))
Amanda
This comment was minimized by the moderator on the site
HI EVERY ONE I NEED HELP IN THIS SYNTEX=IF(AND(AJ=1250,AJ*2.5%),IF(AND(AJ>1250,AJ<=2500),AJ*10%,IF(AND(AJ>2500,AJ<=3750),AJ*15%,IF(AND(AJ>3750,AJ<=11666),AJ*20%))))
THIS FOURMAIL GIVE ME #NAME WHERE THE EROO
This comment was minimized by the moderator on the site
Hi ahmed.dba,
Can you send the file to ? And if you have private information in the file, please delete them.
Amanda
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations