NEED HELP WITH FORMULA

Copper Contributor

This is for myself
=IF(D2<=17.99,E2+2.5 , IF(D2<=19.99 >=17.99,E2+3.5 , IF(D2<=22.99 >=19.99,E2
+4.5 , IF(D2>=22.99 <=27.99,E2+5.5 , IF(D2>=28,E2+4)))))

So what I would like it to say is, if D2 is less than 17.99 add 2.5 to E2,
though if D2 is smaller than or equal to 19.99 but bigger than or equal to
17.99 add 3.5 to E2, though if D2 is smaller than or equal to 27.99 but
bigger than 22.99 then add 5.5 to E2, though if D2 is bigger than 28.00 add
4 to E2


Does this sentence reflect the formula?

2 Replies

@jayzed 

 

Yes, but your syntax is incorrect.

In Excel, this expression: D2<=19.99 >=17.99
would be: AND(D2<=19.99, D2>=17.99)

 

But, it's not really necessary because if your first test (D2<=17.99 ) fails, then D2 must be > 17.99 so there is no need to test that.

 

Also, I would suggest rounding both sides of your conditions to 2 decimals to avoid any problems with double precision point math, which can cause rounding errors at the hardware level (doesn't matter that your data is only to two decimals).

 

=E2+IF(ROUND(D2,2)<=ROUND(17.99,2),2.5,IF(ROUND(D2,2)<=ROUND(19.99,2),3.5,IF(ROUND(D2,2)<=ROUND(22.99,2),4.5,IF(ROUND(D2,2)<=ROUND(27.99,2),5.5,4))))

 

Alternatively, you could create a lookup table (say the table is in A1:B6):
0      2.50
18    3.50
20    4.50
23    5.50
28    4.00

 

Then, your forumula is:
=E2+VLOOKUP(ROUND(D2,2),$A$1:$B$6,2,1)

Thank u so much :smiling_face_with_smiling_eyes: