Home » excel » Excel if and formula

Excel if and formula

Posted by: admin May 14, 2020 Leave a comment

Questions:
 B  C          D        H                    I
Age Years   Salary      Years               Bonus % 
50  12  $120,000.00 <5 years             0.00%
42  20  $40,000.00      5 to 10 years        20.00%
51  3   $97,000.00      11 to 15 years       30.00%
58  28  $105,000.00 16 to 20 years       40.00%
67  6   $78,000.00      20 to 25 years       50.00%
                       26 or more years     100.00%

I am trying to write an if statement the calculates a bonus based on the following:
The employee must be at least 50 years of age
The employee must have at least 5 years of service.
However my statement keeps returning a VALUE
This is what I have

$K$1 = 50
=IF(B2<$K$1,0),IF(C2<5,0),IF(AND(C2>5,C2<10),D2*I3),IF(AND(C2>10,C2<15),D2*I4),IF(AND(C2>15,C2<20),D2*I5),IF(AND(C2>20,C2<25),D2*I6),IF(C2>25,D2*I7)

Please help.

How to&Answers:

You have to nest your IF statements instead of separating them by commas. Your formula should be:

=IF(B2<$K$1,0, IF(C2<5,0, IF(AND(C2>5,C2<10),D2*I3, IF(AND(C2>10,C2<15),D2*I4, IF(AND(C2>15,C2<20),D2*I5, IF(AND(C2>20,C2<25),D2*I6, IF(C2>25,D2*I7)))))))

The parameters for the IF function are logical_test, value_if_true, value_if_false, so the result of the second IF statement becomes the value_if_false for the first one.

Answer:

I prefer a LOOKUP approach – try this

=IF(B2<K$1,0,LOOKUP(C2,{0,5,10,15,20,25},I$2:I$7)*D2)

Answer:

When you receive an error in Excel, a exclamation image pops up when you select the cell with the error. When you bring up the menu by clicking that image, you can select the option to show the calculation steps.

By doing so, you can easily see where it goes wrong: None of your IF statements have a value_if_false defined, resulting in excel to calculate “FALSE, FALSE” after evaluating the first 2 IF statements. Relocate your closing brackets to solve this issue.

=IF(B2<$K$1,0,IF(C2<5,0,IF(AND(C2>5,C2<10),D2*$I$3,IF(AND(C2>10,C2<15),D2*$I$4,IF(AND(C2>15,C2<20),D2*$I$5,IF(AND(C2>20,C2<25),D2*$I$6,IF(C2>25,D2*$I$7)))))))