***************

Following up on last week’s introductory post on using the IF function, here’s one on how to use Excel’s IF statement when you have multiple conditions to meet.

The original question I received from a reader, which prompted this series, was about how to use the IF statement in Excel when you had two conditions that had to be met. For example, when sales fell between a minimum and maximum number. Let’s take a look at our example again. Note that I’ve added the maximum amount of $200K into cell B3:

Before we go further, if you’d like to work through the examples yourself, here’s the raw data you can copy into an Excel worksheet. First, open up a blank excel worksheet. Next, highlight the table below. Copy it, and then go back to your excel worksheet. Go to cell A1 (or another empty cell, if you want to put the data elsewhere), and then select “Edit” from the menu bar. Select “Paste Special” and then “Text” from the popup box. Click “OK”. The data should appear in your Excel worksheet just as it does above.

Bonus | 12% | |

Minimum amount | 100000 | |

Maximum amount | 200000 | |

Sales | Bonus | |

Salesman A | 87925 | |

Salesman B | 100000 | |

Salesman C | 145000 | |

Salesman D | 200750 | |

Salesman E | 178650 | |

Salesman F | 99555 | |

Salesman G | 147000 | |

Salesman H | 213450 | |

Salesman I | 122680 | |

Salesman J | 92500 |

Ok, now back to the tutorial.

Now, let’s suppose sales have to be greater than or equal to $100K **and** less than $200K for a salesman to receive a 12% commission rather than just be greater than $100K, as in our introductory example. How would you write that in “Excel-speak”?

It turns out that you can use Excel’s AND function, which Excel calls a logical operator (just like it calls the IF function). And, as usual, unlike how most other programming languages work, the syntax required in Excel is a bit different. To use it correctly, you have to write it like the following:

**=AND(first condition, second condition, …, etc.)**

(In other programming languages, AND would fall in between each condition, just like how we normally talk, but not in Excel!)

Let’s go back to the concrete example. To write the condition that sales have to fall betwen $100K and $200K for the salesman to receive a 12% commission, we’d write the following in cell C6:

**=IF(AND(B6>=$B$2, B6<$B$3),B6*$B$1,"No bonus")**

Like this:

Translated into plain English, our IF statement now reads, “If B6 is greater than or equal to B2 **and** B6 is less than B3, then multiply B6 by B1. If not, then put ‘No bonus’ into the cell.” In the first case, our salesman didn’t meet the $100K requirement, so the AND function returned a false, so the IF statement put “No bonus” into the cell. By the way, in our case, we only had two conditions to meet, but if we had more, we could just keep adding them into the list of conditions in the parenthese after the AND function.

Here’s how the results look if we do this for all the salesmen in our example:

There are two other logical functions, OR and NOT, which work the exact same way:

**=OR(first condition, second condition, …, etc.)**

**=NOT(first condition, second condition, …, etc.)**

For example, we could actually rewrite our IF statement above using the OR condition if we’re careful. Here’s how it would look:

**=IF(OR(B6<$B$2,B6>=$B$3),”No bonus”, B6*$B$1)**

Like this:

Again, in plain English, what we’re saying is, “If B6 is less than B2 **or** B6 is greater than or equal to B3, put ‘No bonus’ into the cell. Otherwise, multiply B6 by B1.” We’re basically testing for the opposite conditions in our OR statement as we did in our AND statement. And you’ll get the same results as above with the AND statement, as seen below:

You might be able to picture now how you could start using multiple AND, OR, and IF statements nested altogether to test all sorts of complicated conditions in Excel. But keep in mind that cells in Excel are really meant more for doing calculations than programming, which is really what you’re getting into once you start putting in complex IF statements. (I’ve read somewhere you can nest up to 7 IF statements in Excel, though I’m not sure to which version(s) of Excel that limitation applies.)

In particular, coming up with a correct list of conditions to test for, in the right order, that don’t result in a false positive test (e.g. a condition accidentally being met that you didn’t mean to) is a big concern in Excel. The other problem is usability. Even if you were able to come up with a complex IF statement that did what you wanted it to, imagine you put the spreadsheet away and revisited it again in a year’s time when you had to update annual sales figures and calculate bonuses again. Here’s an example of a complicated nested IF statement with no other logical operators:

**=IF(A1<20, A1*1, IF(A1<50, A1*2, IF(A1<100, A1*3, A1*4)))**

Think about it: would you *really* want to spend an extra hour or two decoding that and figure out what you needed to change or update a year later? Similarly, if you had to use a worksheet that someone else wrote that contained a bunch of complicated IF statements, wouldn’t you go nuts? I would!

The statement above is actually even in “reverse” order of what you might normally expect. (In case you’re wondering, I pulled this example from the bottom of a webpage here. It provides the original reader’s question, though why he or she wanted to calculate that, I’m not sure!)

I’ll follow up this post with one on conditional formatting, and I’ve had a request to explain VLOOKUP, HLOOKUP, and pivot tables. Feel free to suggest other tutorials you’d like to see, and I’ll try my best to get to them!

***************************************************

**Look Good at Work and Become Indispensable Become an Excel Pro and Impress Your Boss**

***************************************************

## Ibaad ul Rehman

“I have to compare 2 dates ( one is current date and other date can either old date/future/current date), Current date will be standard date and then have to apply this query-If difference between 2 dates is: More than 3.5 days passed -show “Red”” in next column

if difference between 2 dates is :1 to 3.5 days passed-show “Orange”

if difference between 2 dates is: 0 to 3.5 days remaining show “blue”

if difference is more than 3.5 days remaining then show “green” in next column.

Thanks in advance

## Udayanga Siriwardana

i want to get the result in weekdays( Sunday,Monday,Tuesday,etc….), if Friday=”Monday Realize”,”Next Day”, and Saturday or Sunday=”Tuesday Realize” IN MS EXCEL

## SBaral

Thank u For providing example.

would u Please send me some excell example in mail..

if possible.

thank u

## Tony

Hi, how do I combine the two formulas below in the one cell? it’s been doing my head in, I’ve tried so many formulas from the web without success.

=IF(COUNTIF(G18:K18,”s”),”Suspended”,””)

=IF(COUNTIF(G18:K18,”w”),”Withdrawn”,””)

Basically I want cell F18 to display either:

“Suspended” if cells G18:K18 show an “s” in any cell, or:

display “Withdrawn” if cells G18:K18 show a “w” in any of those cells.

Otherwise, it would display blank, “”.

Please help, it would be much appreciated.

thanks,

Tony

## Annie

I need assistance please with writing an if/and/then statement to return a value as shown below:

if A1109973 and153962 and <=175956,660

otherwise 440

## Annie

Wait that’s not what I wanted. This is what I need help with putting into an if/then/and statement –

if A1 is less than 109973 then 1320

but if A1 is greater than 109973 but less than 131967 then 1100

but if A1 is greater than 131967 but less than 153962 then 660

if A1 is greater than 153962 then 440

## Sarthak Singla

Try this:

=LOOKUP(A1,{0,0;109973,”1320″;131967,”1100″;153962,”660″;”440″})

## Sarthak Singla

Or even this might work:

=IF(AND(A1>0,A1109973,A1131967,A1153962,440))))

## Abhishek

I have two sheets

Sheet1col1,Sheet1col2,Sheet1col3

Hr circle Count

Sheet2col1,Sheet2col2,Sheet2col3

Hr circle Count

Now i want the result :

If Sheet1col1=Sheet2col1 and Sheet1col2=Sheet2col2 then Sheet1col3+Sheet2col3

else Sheet1col3

## John S

I would like to compute Accuracy as a percentage by comparing an “estimated” forecast with “actual” results. For example:

Cell A1 is an estimate of unit production for the week.

Cell A2 is the actual production for the week.

Cell A3 = A2/A1 as a percentage.

I would like A3 to show:

0% if both A1 and A2 are = 0.

Or,

The calculated percentage if both A1 and A2 are > than 0.

Or,

A “string” or large value such as 999% if A1 = 0 but A2 > 0.

I can accomplish the first 2 of these results using an IF(AND) statement, but don’t know how to incorporate another IF or AND to also have the 3rd result present.

## Keith Carroll

Annie: I too wanted basically what you were wanting to be able to calculate commissions. So what I did was I created a formula in a few different cells which then was calculated in another cell to get me the result I want. I want it so that way if it is above a specific amount, then they cap out at that amount, and if it’s less than calculate that amount. If they don’t hit the minimum, then no bonus. So in line with the examples above, I put in the cells next to it, the following; =IF(B6>$B$3,$B$3,0)*$B$1, then in the next cell, =IF(AND(B6>$B$2,B6<$B$3),B6*$B$1,0), and then in the next cell is the final calculation, =IF(SUM(D6:E6)=0,"No Bonus",SUM(D6:E6)). This makes it a little longer, but as I was trying to put it all in one formula, I kept getting errors, so I split it up and then hid the cells that had the calculations.

For your direct questions though, I would do the following next to the cells in question, =SUM(C6:F6) to show the sum, =IF(A6$A$1,A6$A$2,A6$A$3,$B$4,0) to calculate greater than. This is a little more drawn out, but it works and gets the job done without any errors, or banging of the noggin.

## Keith Carroll

Sarthak Singla, the lookup function should be used when you are trying to look up a specific value for a specific item, as in; if I want the price of a specific product in A1, it would be pull the product up (preferably from a drop down menu to enable proper spelling), then the item number and so on, not when trying to calculate items between a specific number.

## S Sealy

Hi I am trying to write an IF formula to calculate residential water rates using the following rate blocs:

$2.48 per m3 (0-8 m3);

$3.10 per m3 (9-20 m3);

$4.66 per m3 (21-40 m3) and

$7.78 per m3 (over 40 m3)

but I am not getting it worked out. Can you please help me. Thanks.

## joe

@S Sealy

A28 – Cost $

B28 – M3

C28 – $ per M3

A28 =IF(B28=9,B28=21,B2841,SUM(B28*7.7),””))))

B28 = number of m3

C28 = =IF(B28=9,B28=21,B2841,”$7.70″,””))))

## joe

This website is shit, it botches your comments.

## MikeS

Thanks for clearing thatup. Much obliged.

## Francine Gabbard

Im trying to calculate PTO:

If ee type is part-time- 0 pto

=IF(F$8=”part-Time”,0)

Set up- years worked Col D$2, D$3, D$4

D$2- 0 year- zero PTO

D$3- 1 years- after 1 year 5 days

D$4- 10 years- after 10 years 10 days

Data-Years worked… Col B

=IF(B11=D$3,5)+IF( B11>=D$4,10)

I cannot get this to work correctly- help

## S Sealy

Thanks Joe for your input but I think your second comment brought some clarity since i do not understand your calculation. Please try to upload it as it should be again.

## Steve

Trying to take old customers out of my Excel file. I have file sorted in Customer name (column B) and then by Date of order (column G), and there are multiple orders by customers.

Customer name is in B2

Date of the order is in G2

So I tried this statement:

=(IF(B2=B1,””,IF(YEAR(G2)<=2020,"delete",""))

That worked for the first customer record but the next customer record returned a blank.

So I tried this statement:

=IF(AND(B9=B8,YEAR(G9)<=2010),"delete","")

That works but not the first record, the subsequent records it returns "delete".

How do I get it to properly mark all the records of the customer who has not placed an order since 2010?

Thanks!

## Karl

I required an IF OR statement where I had a long column of towns in my state (100s) and needed to flag those that were in our sales area.

I initially wrote:

=IF(OR(S:S=”Town1″,”Town2″,”Town3″,”etc…”),”Y”,””)

Turns out it needed to be:

=IF(OR(S:S=”Town1″,S:S=”Town2″,”S:S=”Town3″,”etc….”),”Y”,””)

Just curious as to why my original attempt isn’t adequate and had to put the column reference before each town?

Very interested to hear the answer

## ranit mehta

there is Invoice date is 24/05/2016 amount Rs. 500000/- and collection date is 30/05/2016 Rs.300000/- calculate additional discount 2.5% on 7days 2% on 5days

## ranit mehta

I want to know about debtors ageing formula how to calculate invoice date ageing.

## ranit mehta

Date Debit Credit Balance

24-May-16 652358.00 652358.00 Dr

25-May-16 1251215 652358.00 Dr

26-May-16 252141.00 904499.00 Dr

27-May-16 600000.00 304499.00 Dr

28-May-16 304499.00 Dr

29-May-16 304499.00 Dr

30-May-16 304499.00 Dr

31-May-16 695208.00 999707.00 Dr

1-Jun-16 999707.00 Dr

2-Jun-16 999707.00 Dr

3-Jun-16 999707.00 Dr

4-Jun-16 300000.00 699707.00 Dr

5-Jun-16 699707.00 Dr

6-Jun-16 699707.00 Dr

7-Jun-16 699707.00 Dr

8-Jun-16 699707.00 Dr

9-Jun-16 475000.00 224707.00 Dr

10-Jun-16 100000.00 124707.00 Dr

## scott hart

I need to look at 4 different column values, saying (in English):

IF J2 = “1” or (IF J2 = “2”, B2 = “46”, and Q2 = “PRCL”), return “PTL/Sortation”, otherwise return “BULK”

this is nested in a very lengthy IF formula, but it is the only piece not working as currently written

## A Thangaraj

=IF(and(E2=”AA”,j2=”7″,”Saturday”,IF(and(E2=”AA”,j2=”1″,”Sunday”,IF(and(E2=”AA”,j26,”LEAVE/WO/HOLIDAY”,(IF(E2$I$1,E2$J$1,”ABSENT”,””))))))

it is not working

## TANGIRALA SRINIVAS

In Excel under the head “LOCATION” there are 3 cities namely ‘X’, ‘Y’ and ‘Z’

The % age of HRA under the head “HOUSE RENT ALLOWANCE” is assigned to the cities are ‘X’=30%, ‘Y’=20% and ‘Z’=10% respectively.

I wish to put a condition in the cell under the head “HOUSE RENT ALLOWANCE” that if the location is ‘X’, it should return the value 30%, If ‘Y’, it should return the value 20% and if ‘Z’ it should return 10%

Please help me to insert appropriate function in the cell, to result the desired value

## Lourdes Da Costa

I want the excel formula to be used with the condition if an or to fill in the school fees with the following condition’s

Max kids only 3 kids are allowed for the school fees as per grade.

Emp. Code Name Department Division DOB Joining Date Grade Destination Marital Status No. of Kids Life Insurance Tickets ( self +Spouse+3 kid max) if married School Fee

em-01 10 Amman Married 6

em-02 09 Bahrain Married 2

em-03 08 Kuwait Married 2

em-04 07 Goa Married 1

em-05 06 Kerala Single 0

em-06 05 Spain Married 0

em-07 04 Paris Married 1

em-08 03 London Married 2

em-09 10 Toronto Single 0

em-10 09 Delhi Married 2

em-11 08 Mumbai Single 0

em-12 07 Amman Married 4

em-13 06 Bahrain Single 0

em-14 05 Kuwait Married 5

em-15 04 Goa Single 0

em-16 03 Kerala Married 2

em-17 10 Spain Married 2

em-18 09 Paris Married 1

em-19 08 London Married 3

em-20 07 Toronto Married 3

em-21 06 Delhi Married 3

em-22 05 Mumbai Married 2

em-23 04 Toronto Single 0

School Fees

Grade 1child 2 children 3 children

10 12500 13500 15000

09 10000 11000 12000

08 6500 7500 8500

07 6500 7500 8500

06 5500 6500 7200

05 5500 6500 7200

04 0 0 0

03 0 0 0

## neville

dear sir

I have a problem in excel

I want to calculate the with excel formula for the following problem

I have a amount of say $ 600,000 upto 400,000 the charge is 0.25% above 400,000 it is 0.125% how can I solve the same using if formula

## neville

your way of explain is very good

## bipul

if value is >=+-5%, then yes

## Satyavan

hi, i m trying to if formula for sum query

i want to just clarify for the below said query.

there r sum range i.e

100

199

10000

100001

201

11111

9999

107

250951

now i wanna one of formula to clarify the particular no. belong to some range.

range is if 1 to 200 is LT200, 201 to 10000 is 10K, 10001 to 100000 is 1Lac.

pls help me to resi=olve that

## Barb L

Ok, I’m stumped

Lets say cell B61 is equal to G then I want it to print Gone in R61

BUT if B61 is less than 9, then I want it to take the value of B61 and subtract the total of (F61+I61+L61+O61) and place the total in cell R61

Thanks for any help!

## Mahwish

dear sir

I have a problem in excel

I want to calculate the with excel formula for the following problem there are some grades and foliwng % of bonus amount how 2 criteria match ? using which farmoula to evaluate result

like on if grade is A1 and rating is “B” amount will be 1 salary and if grade will be c3 and rating is “S” amount will be 2 salary

B1+ includes below

23

22

21

20

13

12

11

10

A4

A3

A2

A1

B4

B3

B2

B1

C-D includes below

C4

C3

C2

C1

D5

D4

D3

D2

D1

D0

Rating B1+ C-D

S 3 2

A 2 1

B 1 1.7

C 0.6 1.5

D 0.2 1.3

## Noah

I was hoping that you can help me. Regarding the IF/AND nested formula shown above. You mentioned you can add a third statement after “AND” but if I do that I get an error.

This is what I want to achieve.

Let’s say you have several sales people. You pay their rent, car, and personal expenses. Thus, commissions are tied to a penalty\reward system.

1) If you sale 25,000 – 40,000 – You don’t have to pay back any of the money received

2) if you don’t sale 25,000 you have to pay back 5% of the money received

3) if you sell more than 40,000 you get 5% bonus

This is my formula

=IF(AND($B$12>=B20,$B$12<C20),0,$B$12-C20)

Where

B12 = actual sales

B20 = minimum 25,000

C20 = Maximum 40,000

You can see that I am only calculating the bonus but not the penalty.

Can you please help?

Thanks,

Noah

## Sam

I am trying to do the following. Cell B2 is “male” or “female”. There is a calculation that gives me a number in cell B5. If B5 is >0.95 for Males, then I want “High”. If less than 0.95, I want “low”. For females the threshold for “high” or “low” is 0.80. I want to be able to put either “male” or “female” in B2 and then have excel know which “If” statement to pull. I have tried a few iterations and have not had luck. Thanks

## Lara

Hi! I’m trying to find a formula that says,

If E107 = SCT or CT and C107 is between the dates shown in K1 and K2, then the value in B 107 appears.

I also have a separate cell that populates the value of B107 in a category for SCT (G107) and CT (H107) if that is helpful.

Suggestions?

## John S

Hi,

I am leaving a comment here because of what I am trying to do which is this.

Let me use this example, I have a bible that is in excel format. If one, wanted to search a particular word or phrase in the bible, they can simply use the find command within excel to produce their result.

Now my question is this, I want to do the opposite of that. I am thinking I have to use If statements to create the table I am wanting to put together.

For example, I would like to look at a table that shows me every word that is listed in the bible only six times, and/or any phrase /or phrases that are only together six times in the bible.

If any can be of help that would be greatly appreciated.

Thanks.

## Yvonne

Hello,

I’m trying to analyse some data to see if certain departments are late with taskes and need to do the following If , Then and a formula…or something like that :-)

If H4-K4 is less than 3 then “Late”

If H4 is blank AND Today () – K4 > 3 then “Late”

Otherwise “OK”

Could you help me please?

Thanks

Yvonne

## Yvonne

Sorry – I made an error – that should read

If H4-K4 is greater than 3 then “Late”

If H4 is blank AND Today () – K4 > 3 then “Late”

Otherwise “OK”

## Yvonne

And again I forgot to say I need that to be working days, not calendar days

## Ali

After Greetings

Your assistance will be appreciated in developing a sales incentives formula where it will calculate price list based on total volumes of product.

Examples:

1- If the total monthly volume falls between 450-549, no sales incentive applied.

2- If the total monthly volume falls between 350-449, 1% penalty will be added on the cost price.

3- if the total monthly volume falls between 550-649, 1% bonus will be reduced from the cost price

4- If the total monthly sale exceeds 1000, 4% bonus will be reduced from the cost price.

Your assistance will be highly appreciated.

Ali

aliuae69@gmail.com

## Please Leave a Comment!