+ Reply to Thread
Results 1 to 7 of 7

Need to combine 20 IF statements

  1. #1
    Registered User
    Join Date
    10-04-2013
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    3

    Need to combine 20 IF statements

    Data Priority Grid test calculations.xlsHi everyone, this is my first time on the forum and I really need some help.
    I have a scenario where I need to combine 20 if statements into one formula. I currently have 4 separate nested IF statements with 5 IF statements in each.

    I'm trying to create one formula that defines a priority grid (i.e. whether an item is priority 1,2,3 etc) The criteria I need to evaluate is the Value, whether the status is TRUE or FALSE (this relates to a registration status) and also the number of months - calculated from Today.

    I've attached the excel file which shows the criteria grid as well as the first 4 calculations I've managed to create.

    Essentially I need to combine the follow 5 statements into one formula:

    =IF(AND(A3>=2000000,B3="TRUE"),"1",IF(AND(A3>=2000000,B3="FALSE",DATEDIF(TODAY(),C3,"m")<6),"1",IF(AND(A3>=2000000,B3="FALSE",DATEDIF(TODAY(),C3,"m")>6,DATEDIF(TODAY(),C3,"m")<12),"2",IF(AND(A3>=2000000, B3="FALSE", DATEDIF(TODAY(), C3, "m")>12, DATEDIF(TODAY(),C3,"m")<24),"3",IF(AND(A3>=2000000, B3="FALSE", DATEDIF(TODAY(), C3, "m")>=24),"4")))))

    =IF(AND(A3>=1000000, A3<2000000, B3="TRUE"),"2",IF(AND(A3>=1000000, A3<2000000,B3="FALSE", DATEDIF(TODAY(), C3, "m")<6),"2",IF(AND(A3>=1000000, A3<2000000, B3="FALSE", DATEDIF(TODAY(), C3, "m")>6, DATEDIF(TODAY(), C3,"m")<12),"3",IF(AND(A3>=1000000, A3<2000000,B3="FALSE", DATEDIF(TODAY(), C3, "m")>12, DATEDIF(TODAY(),C3,"m")<24),"4",IF(AND(A3>=1000000, A3<2000000, B3="FALSE", DATEDIF(TODAY(), C3, "m")>=24),"5")))))

    =IF(AND(A3>=500000, A3<1000000, B3="TRUE"),"3",IF(AND(A3>=500000, A3<1000000,B3="FALSE", DATEDIF(TODAY(), C3, "m")<6),"3",IF(AND(A3>=500000, A3<1000000, B3="FALSE", DATEDIF(TODAY(), C3, "m")>6, DATEDIF(TODAY(), C3,"m")<12),"4",IF(AND(A3>=500000, A3<1000000,B3="FALSE", DATEDIF(TODAY(), C3, "m")>12, DATEDIF(TODAY(),C3,"m")<24),"5",IF(AND(A3>=500000, A3<1000000, B3="FALSE", DATEDIF(TODAY(), C3, "m")>=24),"6")))))

    =IF(AND(A3>=200000, A3<500000, B3="TRUE"),"4",IF(AND(A3>=200000, A3<500000,B3="FALSE", DATEDIF(TODAY(), C3, "m")<6),"4",IF(AND(A3>=200000, A3<500000, B3="FALSE", DATEDIF(TODAY(), C3, "m")>6, DATEDIF(TODAY(), C3,"m")<12),"5",IF(AND(A3>=200000, A3<500000,B3="FALSE", DATEDIF(TODAY(), C3, "m")>12, DATEDIF(TODAY(),C3,"m")<24),"6",IF(AND(A3>=200000, A3<500000, B3="FALSE", DATEDIF(TODAY(), C3, "m")>=24),"7")))))

    Any help would be greatly appreciated as I'm now completely stuck :-)
    Last edited by CatMac; 10-04-2013 at 07:05 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,380

    Re: Need to combine 20 IF statements

    I'm not going to do it for you as it looks like hard work, but you have various conditions where the outcome is the same value. Therefore, you can OR these conditions instead of cascading down through an IF hierarchy. So, what I'm saying is that you have different conditions that result in a value of 1, 2, 3, etc.

    As an example:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    could be:

    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Only a little shorter in its own right but you can group all the conditions resulting in a value of 2 with "OR", all the conditions for 3, and so on.

    Have a go, see how you get on.

    Also, note that "1" is not the same as 1. The first, "1", is a text value, 1, without quotes, is numeric.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,380

    Re: Need to combine 20 IF statements

    Just to highlight:

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    10-04-2013
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Need to combine 20 IF statements

    Thanks very much. I had a sneaky suspicion that it would make sense to use an OR statement but for the life of me couldn't figure it out. Will give it a bash.
    Appreciate the help

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,380

    Re: Need to combine 20 IF statements

    You're welcome.

  6. #6
    Registered User
    Join Date
    10-04-2013
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Need to combine 20 IF statements

    Me again I'm afraid. Tried doing the OR AND variation but doesn't appear to be working. Well it seems to work on only some of the variations. I've tried doing them for the return values of 1 and 2 but the formula seems to be selective in terms of which AND function it wants to accept. Not making much sense I know but perhaps you could have a look at the calculations and attached sheet if you have a minute

    =IF(OR(AND(A3>=2000000,B3="TRUE"),AND(A3>=2000000,B3="FALSE",DATEDIF(TODAY(),C3,"m")<6)),1)

    =IF(OR(AND(A5>=2000000,B5="FALSE",DATEDIF(TODAY(),C5,"m")>6,DATEDIF(TODAY(),C5,"m")<12),AND(A9>=1000000, A9<2000000, B9="TRUE"),AND(A9>=1000000, A9<2000000,B9="FALSE", DATEDIF(TODAY(), C9, "m")<6)),2,)

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,380

    Re: Need to combine 20 IF statements

    Simplified and combined:

    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Seems to come out with the right answers. I don't think you can OR the conditions, as it starts with the basic premise, is A > a value, then is B True or False, then how many months.


    Regards, TMS

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Need help to combine to VBA Statements
    By SamCV in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-06-2013, 02:01 PM
  2. Need to combine several IF statements together
    By SumTuck in forum Excel General
    Replies: 7
    Last Post: 06-12-2012, 12:25 PM
  3. [SOLVED] Combine 3 IF Statements
    By kilipo in forum Excel General
    Replies: 2
    Last Post: 04-28-2012, 07:26 AM
  4. Combine two IF statements
    By dpask in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 12-07-2011, 04:41 PM
  5. How to combine two IF statements together.
    By foad in forum Excel General
    Replies: 7
    Last Post: 03-13-2009, 05:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1