Is it possible to simplify these chained IF statements without lookup table?

strangebiscuit

New Member
Joined
Nov 25, 2013
Messages
35
Pardon, I know this is rather confusing...I'm just having trouble thinking of how to simplify this and wondered if anyone had any ideas they'd care to share.

I started writing a formula recently with a bunch of nested IF statements that's kind of spiraled out of control. I'm wondering if anyone has any ideas of how to simplify it without the need for creating a separate sheet and using VLOOKUP.

Basically, this is supposed to calculate a payment amount based on number of points earned in B36 and number of days in attendance (maximum of "6") in B37 and place it in the cell below - B38. So once again, points in B36, attendance in B37, result in B38.

While the points total in B36 is less than 10:
  • If the attendance in B37 is 6 (the maximum)...the total in B38 should be 250.
  • If B37 is 5...the total (B38) should be 210
  • If B37 is 4...the total (B38) should be 168.
  • If B37 is 3...the total (B38) should be 126.
  • If B37 is 2...the total (B38) should be 84.
  • If B37 is 1...the total (B38) should be 42.

Then when points total in B36 is more than 10...there are a series of tiers it can fall into where, if attendance (B37) is at the maximum of 6...the total in B38 should be raised. In all of these tiers, 40 is subtracted from total in B38 each time attendance (B37) drops by 1. So for example:

While the points total in B36 is between 10 and 14:
  • If the attendance in B37 is 6 (the maximum)...the total in B38 should be 350.
  • If B37 is 5...the total (B38) should be 310...(350-40)
  • If B37 is 4...the total (B38) should be 270.
  • If B37 is 3...the total (B38) should be 230.
  • If B37 is 2...the total (B38) should be 190.
  • If B37 is 1...the total (B38) should be 150.

The other tiers are as such:
  • B36 between 15 and 19 and B37 = 6: 400
  • B36 between 20 and 24 and B37 = 6: 450
  • B36 25 or more and B37 = 6: 500
I chained a couple of nested IF statements together when it was just two tiers, but as the additional tiers were added it's gotten very messy and I believe one more tier would put it over the maximum value count for XLS. Here's the horrible jumble of IF statements as they stand now:

Code:
=IF(OR(B36<0,B37=0),0,IF(AND(AND(B36<10),B37=6),250,IF(AND(B36<10,B37=5),210,IF(AND(B36<10,B37=4),168,IF(AND(B36<10,B37=3),126,IF(AND(B36<10,B37=2),84,IF(AND(B36<10,B37=1),42,0)))))))+IF(AND(AND(B36>=10,B36<15),B37=6),350,IF(AND(AND(B36>=10,B36<15),B37=5),310,IF(AND(AND(B36>=10,B36<15),B37=4),270,IF(AND(AND(B36>=10,B36<15),B37=3),230,IF(AND(AND(B36>=10,B36<15),B37=2),190,IF(AND(AND(B36>=10,B36<15),B37=1),150,0))))))+IF(AND(AND(B36>=15,B36<20),B37=6),400,IF(AND(AND(B36>=15,B36<20),B37=5),360,IF(AND(AND(B36>=15,B36<20),B37=4),320,IF(AND(AND(B36>=15,B36<20),B37=3),280,IF(AND(AND(B36>=15,B36<20),B37=2),240,IF(AND(AND(B36>=15,B36<20),B37=1),200,0))))))+IF(AND(AND(B36>=20,B36<25),B37=6),450,IF(AND(AND(B36>=20,B36<25),B37=5),410,IF(AND(AND(B36>=20,B36<25),B37=4),370,IF(AND(AND(B36>=20,B36<25),B37=3),330,IF(AND(AND(B36>=20,B36<25),B37=2),290,IF(AND(AND(B36>=20,B36<25),B37=1),250,0))))))+IF(AND(B36>=25,B37=6),500,IF(AND(B36>=25,B37=5),460,IF(AND(B36>=25,B37=4),420,IF(AND(B36>=25,B37=3),380,IF(AND(B36>=25,B37=2),340,IF(AND(B36>=25,B37=1),300,0))))))IF(AND(B36>=25,B37=6),500,IF(AND(B36>=25,B37=5),460,IF(AND(B36>=25,B37=4),420,IF(AND(B36>=25,B37=3),380,IF(AND(B36>=25,B37=2),340,IF(AND(B36>=25,B37=1),300,0))))))

I certainly understand if this is too much for anyone to fathom, and realize the obvious suggestion is to use a lookup table on another sheet...again, just wondering if anyone else had any other methods that might work. It has to be live updating so putting the whole thing into a regular VBA macro wouldn't work.

Thanks very much in advance for anyone who takes the trouble to even look at this!
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
[I see my post above didn't have the table included; I'm having quite the struggle using this forum text editor with MS Edge.]

Here is a lookup table:

ABCDEFGHIJK
30LOOKUP TABLE
31points
320111520251E+308
336250350400450500
345210310
35attendance4168270
36points183126230
37attendance6284190
38RESULT400142150

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet2

Worksheet Formulas
CellFormula
K32= 9.99999999999999E+307
B38=INDEX(G33:K38,MATCH(B37,E33:E38,0),MATCH(B36,F32:K32,1))

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0
Did you see my post #7?

Yeah I did, I think you're onto something clever with it...Hercules1946 suggested something similar as well.

Modified for my purposes it would be something like: =IF(B36<10,B37*42,IF(B36<15,150+40*(B37-1),IF(B36<20,200+40*(B37-1),IF(B36<25, 250+40*(B37-1), 300+40*(B37-1)))))

This almost works except for two things...
1.For the < 10 tier if attendance (B37) is 6...the total should be 250. This evaluates to 252 is this instance.
2. If attendance (B37) <= 0 in any tier the total should be 0.
 
Upvote 0
You can dispense with the lookup table by hard-coding it into the formula; put this in B38:

Code:
=INDEX({250,350,400,450,500;210,310,0,0,0;168,270,0,0,0;126,230,0,0,0;84,190,0,0,0;42,150,0,0,0},MATCH(B37,{6;5;4;3;2;1},0),MATCH(B36,{0,11,15,20,25,9.99999999999999E+307},1))
 
Upvote 0
Yeah I did, I think you're onto something clever with it...Hercules1946 suggested something similar as well.

Modified for my purposes it would be something like: =IF(B36<10,B37*42,IF(B36<15,150+40*(B37-1),IF(B36<20,200+40*(B37-1),IF(B36<25, 250+40*(B37-1), 300+40*(B37-1)))))

This almost works except for two things...
1.For the < 10 tier if attendance (B37) is 6...the total should be 250. This evaluates to 252 is this instance.
2. If attendance (B37) <= 0 in any tier the total should be 0.

OK, I missed the celing, adjusted to this...
=IF(A2>0,IF(A1<10,MIN(250,A2*42),MIN(350,150+40*(A2-1))),"")
 
Last edited:
Upvote 0
Nice! I've now got two viable solutions that do exactly what I require!

One based on FDibbins's (and Hercules1946's) suggestions:

=IF(B37<=0,0,IF(B36<10,MIN(250,B37*42),IF(B36<15,MIN(350, 150+40*(B37-1)),IF(B36<20,MIN(400, 200+40*(B37-1)),IF(B36<25, MIN(450, 250+40*(B37-1)), MIN(500, 300+40*(B37-1)))))))

And another based on DRSteele's hard-coded lookup table suggestion:

=INDEX({250,350,400,450,500;210,310,360,410,460;168,270,320,370,420;126,230,280,330,380;84,190,240,290,340;42,150,200,250,300;0,0,0,0,0},MATCH(B37,{6;5;4;3;2;1;0},0),MATCH(B36,{-1000,10,15,20,25,9.99999999999999E+307},1))

Both work pretty much perfectly for my purposes. The first one (IF) is a bit shorter and maybe a little easier to read, but the second (INDEX) would be more flexible if I need to apply it to a similar structure that's got a less straightforward mathematical pattern.

Thanks so much to everyone who replied...I learned a lot from this. This forum is a total godsend.
 
Upvote 0
For all the tiers after the "points < 10" group (so tier 2 - 5) it's supposed to be that each time attendance (B37) goes down by 1, 40 is subtracted ...

So... just to be clear, my formula in #9 needs amending so that tiers 3, 4, and 5 for each drop in attendance below 6, 40 needs to be subtracted? e.g. if B37 = 3, then:
Tier 3 =280, Tier 4 = 330 and Tier 5 = 380.

If all that is correct then this formula should do it:
=IF(B36<10, 42*B37,IF(B36<=14, ((B37-1)*40)+150,IF(B36<=19,((B37-1)*40)+200,IF(B36<=24,((B37-1)*40)+250,IF(B36>=25,((B37-1)*40)+300,"")))))
Just another thought .... If you have a spare cell to hold the formula ((B37-1) * 40) the main formula would be much simpler.
Let me know how you get on with it. :)
 
Last edited:
Upvote 0
J.. If you have a spare cell to hold the formula ((B37-1) * 40) the main formula would be much simpler.
Let me know how you get on with it. :)

My last effort :) This sorts out the 250 ceiling, and simplifies by holding the repeated expression in A1 (e.g.)

=IF(B36<10, MIN(42*B37,250),IF(B36<=14, $A$1+150,IF(B36<=19,$A$1+200,IF(B36<=24,$A$1+250,IF(B36>=25,$A$1+300,"")))))
 
Upvote 0

Forum statistics

Threads
1,215,143
Messages
6,123,276
Members
449,093
Latest member
Vincent Khandagale

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top