Shorten Nested if AND Formula

mohdamir1989

New Member
Joined
Oct 17, 2017
Messages
42
Hello all,

I have a formula as below working very well I just want it shortened and clean if by any way possible. It is self explanatory still I can explain if required

Basically If checking from M column if right 3 words equals Bel and AB is equals or less than 72 hours it will be writing "L1" so changing hours will result different levels.

=IF(AND(RIGHT(M1223,3)="Bel",AB1223<=72),"L1",IF(AND(RIGHT(M1223,3)="Bel",AB1223<=96),"L2",IF(AND(RIGHT(M1223,3)="Bel",AB1223<=144),"L3",IF(AND(RIGHT(M1223,3)="ase",AB1223<=48),"L1",IF(AND(RIGHT(M1223,3)="ase",AB1223<=72),"L2",IF(AND(RIGHT(M1223,3)="ase",AB1223<=120),"L3",""))))))

Your experience sharing is highly appreciated

Best Regards
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Hi, if you wanted to stick with nested IF()'s here is one alternative:

Code:
=IF(RIGHT(M1223,3)="bel",IF(AB1223<=72,"L1",IF(AB1223<=96,"L2",IF(AB1223<=144,"L3",""))),IF(RIGHT(M1223,3)="Ase",IF(AB1223<=48,"L1",IF(AB1223<=72,"L2",IF(AB1223<=120,"L3",""))),""))

Or for a different approach entirely..:

Code:
=IFNA("L"&4-MATCH(AB1223,CHOOSE(MATCH(RIGHT(M1223,3),{"Bel","Ase"},0),{144,96,72},{120,72,48}),-1),"")
 
Last edited:
Upvote 0
Hello,
Not sure which excel version you are using.
Try with countifs which works on below versions.
[FONT=&quot] [/FONT][FONT=&quot][/FONT][FONT=&quot]Excel 2016[/FONT][FONT=&quot] [/FONT][FONT=&quot]Excel 2013[/FONT][FONT=&quot] [/FONT][FONT=&quot]Excel 2010[/FONT][FONT=&quot] [/FONT][FONT=&quot]Excel 2007[/FONT]
 
Upvote 0
Try this

=IF(RIGHT(A1,3)="Bel",LOOKUP(A2,{0,"L1";73,"L2";97,"L3";145,""}),IF(RIGHT(A1,3)="ase",LOOKUP(A2,{0,"L1";49,"L2";73,"L3";121,""}),""))
 
Upvote 0
Hi, if you wanted to stick with nested IF()'s here is one alternative:

Code:
=IF(RIGHT(M1223,3)="bel",IF(AB1223<=72,"L1",IF(AB1223<=96,"L2",IF(AB1223<=144,"L3",""))),IF(RIGHT(M1223,3)="Ase",IF(AB1223<=48,"L1",IF(AB1223<=72,"L2",IF(AB1223<=120,"L3",""))),""))

Or for a different approach entirely..:

Code:
=IFNA("L"&4-MATCH(AB1223,CHOOSE(MATCH(RIGHT(M1223,3),{"Bel","Ase"},0),{144,96,72},{120,72,48}),-1),"")

Thank you FormR for kind help and sharing experience. Second formula is returning #NAME ? error. Maybe I'm missing something.

Best Regards
 
Upvote 0
Second formula is returning #NAME ? error. Maybe I'm missing something.

Hi, IFNA() is only available in XL2013+ you can try using IFERROR() instead:

Code:
=IFERROR("L"&4-MATCH(AB1223,CHOOSE(MATCH(RIGHT(M1223,3),{"Bel","Ase"},0),{144,96,72},{120,72,48}),-1),"")
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,636
Latest member
laura12345

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