How can I create an alternative to 28 levels of nested IF's?

JeffGrant

Well-known Member
Joined
Apr 7, 2021
Messages
516
Office Version
  1. 365
Platform
  1. Windows
Hi All,

recently my model has started to give me Circular Errors that I have not had before. (Maybe because I did and Office 365 update). I read somewhere that if there are too many IF's that this could cause the problem. And indeed elsewhere in the model, I changed a multi level IF statement and that circular error was fixed. So I guess there is a truth to the statement.

However, in this case, I am not sure what to do. I have an equation which is 28 levels deep with a nested IF. All of the examples and videos I have seen using alternatives to Nested If's are very simplistic and don't really give me any help. The aim of this formula is to identify patterns in the numbers, such that:

If:
A4 = B4, B4 = C4, C4 = D4, the pattern is "same same same"

Or If
A4 < B4, B4 > C4, C4 < D4, the pattern is "up down up" and so on.

Currently, the nested IF's pulls out 26 different patterns.

I am not sure how to construct an IFS, CHOOSE or VLOOKUP equation that can replace this nested IF rats nest to fix the circular reference.

Can somebody please give me a big push into the direction I should be heading.

Thanks


Book2
ABCDE
1
2Numerical Equivalent from All ClassesDecider Equation
3321This Race
4216240230240up down up
5210210210208same same down
6210212210210up down same
7294210210210down same same
8210210230218same up down
9218230218218up down same
10257212218218down up same
11210210210208same same down
12210210210208same same down
13210210210208same same down
14272258257258down down up
15240240216Do Not Bet
16240254254254up same same
17232220224232down up up
18224216216196down same down
19212204216230down up up
20266230232198down up down
Sheet1
Cell Formulas
RangeFormula
E4:E13E4= IF(OR(A4="",B4="",C4="",D4=""),"Do Not Bet", IF(AND(A4=B4,A4=C4,A4=D4),"same same same",IF(AND(A4=B4,A4=C4,C4>D4),"same same down", IF(AND(A4>B4,B4<C4,D4<C4),"down up down",IF(AND(A4<B4,B4=C4,D4<C4),"up same down", IF(AND(A4>B4,B4=C4,B4=D4),"down same same",IF(AND(A4=B4,C4<B4,D4<C4),"same down down", IF(AND(A4=B4,B4<C4,D4=C4),"same up same",IF(AND(A4=B4,A4=C4,D4>C4),"same same up", IF(AND(A4<B4,B4=C4,C4=D4),"up same same",IF(AND(A4=B4,B4<C4,C4>D4),"same up down", IF(AND(A4>B4,B4>C4,C4=D4),"down down same",IF(AND(A4=B4,B4>C4,C4=D4),"same down same", IF(AND(A4<B4,B4<C4,C4>D4),"up up down",IF(AND(A4<B4,B4=C4,C4,D4),"up same up", IF(AND(A4>B4,B4<C4,C4=D4),"down up same",IF(AND(A4>B4,B4>C4,C4>D4),"down down down", IF(AND(A4>B4,B4<C4,C4<D4),"down up up",IF(AND(A4=B4,B4<C4,C4<D4),"same up up", IF(AND(A4=B4,B4>C4,C4<D4),"same down up",IF(AND(A4<B4,B4>C4,C4>D4),"up down down", IF(AND(A4>B4,B4=C4,C4<D4),"down same up",IF(AND(A4<B4,B4>C4,C4=D4),"up down same", IF(AND(A4<B4,B4<C4,C4<D4),"up up up",IF(AND(A4>B4,B4>C4,C4<D4),"down down up", IF(AND(A4<B4,B4>C4,C4<D4),"up down up",IF(AND(A4<B4,B4<C5,C4=D4),"up up same", IF(AND(A4>B4,B4=C4,C4>D4),"down same down","Do Not Bet"))))))))))))))))))))))))))))
E14E14= IF(OR(A14="",B14="",C14="",D14=""),"Do Not Bet", IF(AND(A14=B14,A14=C14,A14=D14),"same same same",IF(AND(A14=B14,A14=C14,C14>D14),"same same down", IF(AND(A14>B14,B14<C14,D14<C14),"down up down",IF(AND(A14<B14,B14=C14,D14<C14),"up same down", IF(AND(A14>B14,B14=C14,B14=D14),"down same same",IF(AND(A14=B14,C14<B14,D14<C14),"same down down", IF(AND(A14=B14,B14<C14,D14=C14),"same up same",IF(AND(A14=B14,A14=C14,D14>C14),"same same up", IF(AND(A14<B14,B14=C14,C14=D14),"up same same",IF(AND(A14=B14,B14<C14,C14>D14),"same up down", IF(AND(A14>B14,B14>C14,C14=D14),"down down same",IF(AND(A14=B14,B14>C14,C14=D14),"same down same", IF(AND(A14<B14,B14<C14,C14>D14),"up up down",IF(AND(A14<B14,B14=C14,C14,D14),"up same up", IF(AND(A14>B14,B14<C14,C14=D14),"down up same",IF(AND(A14>B14,B14>C14,C14>D14),"down down down", IF(AND(A14>B14,B14<C14,C14<D14),"down up up",IF(AND(A14=B14,B14<C14,C14<D14),"same up up", IF(AND(A14=B14,B14>C14,C14<D14),"same down up",IF(AND(A14<B14,B14>C14,C14>D14),"up down down", IF(AND(A14>B14,B14=C14,C14<D14),"down same up",IF(AND(A14<B14,B14>C14,C14=D14),"up down same", IF(AND(A14<B14,B14<C14,C14<D14),"up up up",IF(AND(A14>B14,B14>C14,C14<D14),"down down up", IF(AND(A14<B14,B14>C14,C14<D14),"up down up",IF(AND(A14<B14,B14<C14,C14=D14),"up up same", IF(AND(A14>B14,B14=C14,C14>D14),"down same down","Do Not Bet"))))))))))))))))))))))))))))
E15:E20E15=IF(OR(A15="",B15="",C15="",D15=""),"Do Not Bet",IF(AND(A15=B15,A15=C15,A15=D15),"same same same",IF(AND(A15=B15,A15=C15,C15>D15),"same same down",IF(AND(A15>B15,B15<C15,D15<C15),"down up down",IF(AND(A15<B15,B15=C15,D15<C15),"up same down",IF(AND(A15>B15,B15=C15,B15=D15),"down same same",IF(AND(A15=B15,C15<B15,D15<C15),"same down down",IF(AND(A15=B15,B15<C15,D15=C15),"same up same",IF(AND(A15=B15,A15=C15,D15>C15),"same same up",IF(AND(A15<B15,B15=C15,C15=D15),"up same same",IF(AND(A15=B15,B15<C15,C15>D15),"same up down",IF(AND(A15>B15,B15>C15,C15=D15),"down down same",IF(AND(A15=B15,B15>C15,C15=D15),"same down same",IF(AND(A15<B15,B15<C15,C15>D15),"up up down",IF(AND(A15<B15,B15=C15,C15,D15),"up same up",IF(AND(A15>B15,B15<C15,C15=D15),"down up same",IF(AND(A15>B15,B15>C15,C15>D15),"down down down",IF(AND(A15>B15,B15<C15,C15<D15),"down up up",IF(AND(A15=B15,B15<C15,C15<D15),"same up up",IF(AND(A15=B15,B15>C15,C15<D15),"same down up",IF(AND(A15<B15,B15>C15,C15>D15),"up down down",IF(AND(A15>B15,B15=C15,C15<D15),"down same up",IF(AND(A15<B15,B15>C15,C15=D15),"up down same",IF(AND(A15<B15,B15<C15,C15<D15),"up up up",IF(AND(A15>B15,B15>C15,C15<D15),"down down up",IF(AND(A15<B15,B15>C15,C15<D15),"up down up",IF(AND(A15<B15,B15<C15,C15=D15),"up up same",IF(AND(A15>B15,B15=C15,C15>D15),"down same down", "Do Not Bet"))))))))))))))))))))))))))))
 
The circular reference tracker is, in my experience, quite infuriating. I often just clear entire columns one by one until it stops reporting a CR, then reinstate the last one deleted and check again. If the CR reappears, at least I know it should be in the column just reinstated.
 
Upvote 0

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Ok, looks like my primary file has corrupted. I have opened a copy from two days ago and there aren't any c.r.s

I'll work from that file.

thanks for your help.
 
Upvote 0
Not sure exactly what you came up with but what about this as a replacement for that very long formula?

JeffGrant.xlsm
ABCDE
3321This Race
4216240230240up down up
5210210210208same same down
6210212210210up down same
7294210210210down same same
8210210230218same up down
9218230218218up down same
10257212218218down up same
11210210210208same same down
12210210210208same same down
13210210210208same same down
14272258257258down down up
15240240216Do Not Bet
16240254254254up same same
17232220224232down up up
18224216216196down same down
19212204216230down up up
20266230232198down up down
Sheet1
Cell Formulas
RangeFormula
E4:E20E4=IF(COUNT(A4:D4)=4,TEXTJOIN(" ",1,CHOOSE(SIGN(B4:D4-A4:C4)+2,"down","same","up")),"Do Not Bet")
Good Morning Peter_SSs,

I appologise that I didn't look at this last night. I guess I got so carried with with multitude of c.r's that appeared from no where that I had to put everything aside for a while.

I am just in awe of the knowledge in this forum. This formula is fantastic at is the preferred solution that will be implemented today.

Thank you kindly.
 
Upvote 0

Forum statistics

Threads
1,214,978
Messages
6,122,547
Members
449,089
Latest member
davidcom

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