+ Reply to Thread
Results 1 to 13 of 13

Nesting issues

  1. #1
    Registered User
    Join Date
    11-12-2009
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2007
    Posts
    4

    Nesting issues

    I don't have a lot of experience with excel, and I'm trying to use an IF statement with 15 nested IFs. I cannot save it as xlsx because the document needs to be in a format accessible to people with older computers. Is there a way I can get around this by using another type of statement?

    Thanks so much. I appreciate any help. If someone thinks they can I'd be happy to send them the actual formula I am working on.

    Shmem

  2. #2
    Forum Expert darkyam's Avatar
    Join Date
    03-05-2008
    Location
    Houston, TX
    MS-Off Ver
    2013
    Posts
    2,191

    Re: Nesting issues

    Welcome to the forum. Yes, we would need to see the formula you're working with to help. Often, Lookup, Vlookup, or some Index/Match function can take the place a long series of nested Ifs.

  3. #3
    Registered User
    Join Date
    11-12-2009
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Nesting issues

    Wow that was fast. Thanks! Here is the formula. It works when I have only a few statements in there, so I know that much works at least.

    =if(and((E181=0),(E183=0),(L709<>""),(E185=0)),(((SUM(N181:O186))/30)*100),IF(AND((E181=0),(E183=0),(L709<>"")),(((SUM(N181:O186))/50)*100),IF(AND((E181=0),(L709<>""),(E185=0)),(((SUM(N181:O186))/50)*100),IF(AND((E181=0),(E183=0),(E185=0)),(((SUM(N181:O186))/45)*100),IF(AND((E182=0),(L709<>""),(E185=0)),(((SUM(N181:O186))/45)*100),IF(AND((E181=0),(E183=0)),(((SUM(N181:O186))/65)*100),IF(AND((E181=0),(L709<>"")),(((SUM(N181:O186))/65)*100),IF(AND((E181=0),(E185=0)),(((SUM(N181:O186))/65)*100),IF(AND((E182=0),(L709<>"")),(((SUM(N181:O186))/65)*100),IF(AND((L709<>""),(E185=0)),(((SUM(N181:O186))/65)*100),IF(AND((E182=0),(E185=0)),(((SUM(N181:O186))/60)*100),IF(E181=0),(((SUM(N181:O186))/85)*100),IF(E182=0,(((SUM(N181:O186))/80)*100),IF(L709<>"",(((SUM(N181:O186))/85)*100),IF(E185=0,(((SUM(N181:O186))/80)*100),((SUM(N181:O186))))))))))

    In case you need to know what I'm trying to do - I'm trying to sum up a group of cells and that sum will be divided by a number that depends on 4 cells, and how many/what combination of them are equal to zero (or blank for the case of L709). Is this confusing? It's hard to explain!

  4. #4
    Forum Expert darkyam's Avatar
    Join Date
    03-05-2008
    Location
    Houston, TX
    MS-Off Ver
    2013
    Posts
    2,191

    Re: Nesting issues

    You use E181, E182, E183, E185, and L709. Which of those is not included in the four that this formula depends on. Also, it seems that each of these has a value that they take away from 100. E182, E183, and E185 seem to take away 20 from the divisor each if not blank while the other two take off .15 each, yet that doesn't seem entirely consistent as with your four cells in the first IF all evaluating to true, only 70 is taken off rather than 75. Do they each have values assigned and, if so, what are these values for each cell?
    This formula can be much simpler if this is the case, although I can make it work if it is not.

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Nesting issues

    Can you create a logic table showing each of the calcs and the possible results individually. If you stack up the 15 inidividual possibilities in sequence of importance, then perhaps a pattern will immediately jump out to us that is no evident in the IF/IF/IF/IF/IF layout.

    Often, when single calc gets this convoluted, it's time to add some helper columns to do some of the interim testing.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  6. #6
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Nesting issues

    urk!
    Please post an example, it is confusing if you aren't familiar with the data,

    CC

  7. #7
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Nesting issues

    if you split it like this you can see where the errors are
    =if(and((E181=0),(E183=0),(L709<>""),(E185=0)),(((SUM(N181:O186))/30)*100),
    IF(AND((E181=0),(E183=0),(L709<>"")),(((SUM(N181:O186))/50)*100),
    IF(AND((E181=0),(L709<>""),(E185=0)),(((SUM(N181:O186))/50)*100),
    IF(AND((E181=0),(E183=0),(E185=0)),(((SUM(N181:O186))/45)*100),
    IF(AND((E182=0),(L709<>""),(E185=0)),(((SUM(N181:O186))/45)*100),
    IF(AND((E181=0),(E183=0)),(((SUM(N181:O186))/65)*100),
    IF(AND((E181=0),(L709<>"")),(((SUM(N181:O186))/65)*100),
    IF(AND((E181=0),(E185=0)),(((SUM(N181:O186))/65)*100),
    IF(AND((E182=0),(L709<>"")),(((SUM(N181:O186))/65)*100),
    IF(AND((L709<>""),(E185=0)),(((SUM(N181:O186))/65)*100),
    IF(AND((E182=0),(E185=0)),(((SUM(N181:O186))/60)*100),
    IF(E181=0),(((SUM(N181:O186))/85)*100),
    IF(E182=0,(((SUM(N181:O186))/80)*100),
    IF(L709<>"",(((SUM(N181:O186))/85)*100),
    IF(E185=0,(((SUM(N181:O186))/80)*100),((SUM(N181:O186))))))))))
    and there need to be 15 ")" at the end to match the number of ifs
    you can also remove most of the ()
    eg
    =if(and(E181=0,E183=0,L709<>"",E185=0),(SUM(N181:O186)/30)*100,
    IF(AND(E181=0,E183=0,L709<>""),(SUM(N181:O186)/50)*100,
    IF(AND(E181=0,L709<>"",E185=0),(SUM(N181:O186)/50)*100,
    IF(AND(E181=0,E183=0,E185=0),(SUM(N181:O186)/45)*100,
    IF(AND(E182=0,L709<>"",E185=0),(SUM(N181:O186)/45)*100,
    IF(AND(E181=0,E183=0),(SUM(N181:O186)/65)*100,
    IF(AND(E181=0,L709<>""),(SUM(N181:O186)/65)*100,
    IF(AND(E181=0,E185=0),(SUM(N181:O186)/65)*100,
    IF(AND(E182=0,L709<>""),(SUM(N181:O186)/65)*100,
    IF(AND(L709<>"",E185=0),(SUM(N181:O186)/65)*100,
    IF(AND(E182=0,E185=0),(SUM(N181:O186)/60)*100,
    IF(E181=0,(SUM(N181:O186)/85)*100,
    IF(E182=0,(SUM(N181:O186)/80)*100,
    IF(L709<>"",(SUM(N181:O186)/85)*100,
    IF(E185=0,(SUM(N181:O186)/80)*100,SUM(N181:O186))))))))))))))))
    but im sure there is a better solution!
    Last edited by martindwilson; 11-12-2009 at 07:35 PM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  8. #8
    Forum Expert darkyam's Avatar
    Join Date
    03-05-2008
    Location
    Houston, TX
    MS-Off Ver
    2013
    Posts
    2,191

    Re: Nesting issues

    One thing that would help, just in the eyesore dept., is to take out all the instances of SUM(N181:O186) and put just one at the beginning of the formula before the If statements begin. Also, remove *100 and stick it after the Ifs just once. It's possible to do this with just seven nested Ifs, but I'm waiting on which of the five cells you listed is a typo or whether saying it was four cells was the typo.

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Nesting issues

    If the E182 is a typo then the formula can be done as

    =SUM(N181:O186) * 100 / choose((e181=0) + 2*(e183=0) + 4*(L709="") + 8*(E185=0), x,x,x,x,x,x,x,x,x,x,x,x,x,x,x)

    where the x's are the 16 possible divisors (some duplicated) based on the comparisons.

    If there really are 5 variables,

    =SUM(N181:O186) * 100 / index(divisorList, (e181=0) + 2*(E182=0) + 4*(e183=0) + 8*(L709="") + 16*(E185=0))
    Entia non sunt multiplicanda sine necessitate

  10. #10
    Forum Expert darkyam's Avatar
    Join Date
    03-05-2008
    Location
    Houston, TX
    MS-Off Ver
    2013
    Posts
    2,191

    Re: Nesting issues

    If each cell takes off a given amount from the divisor, you could use =SUM(N181:O186)*100/(100-((E181=0)*.15+(E183=0)*.2+(E185=0)*.2+(L709<>"")*.15)), adjusting the multiplier for each cell as necessary.

  11. #11
    Registered User
    Join Date
    11-12-2009
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Nesting issues

    Wow. I am overwhelmed with the help. Thanks!

    I did make a mistake - sorry! There should be no E183 values. It should be E182.
    You are right darkyam - each of the cells does take off a given amount from 100. I am creating a final score for a document, and when some sections are not applicable I have to weight the final score differently. So, for example, if section A (cell E181) is not applicable - and therefore equal to 0, the total is now scored out of 85 instead of out of 100.

    Here are the values that will be subtracted from 100 for each cell (and they are cumulative).
    E181 - 15
    E182 - 20
    L709 - 15
    E185 - 20

    I know it's complicated - I'm not sure how to explain it any better.

  12. #12
    Forum Expert darkyam's Avatar
    Join Date
    03-05-2008
    Location
    Houston, TX
    MS-Off Ver
    2013
    Posts
    2,191

    Re: Nesting issues

    You should be able to use my formula then, replacing E183 with E182, or shg's first one, if you prefer.

  13. #13
    Registered User
    Join Date
    11-12-2009
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Nesting issues

    Thanks again. I am going to try them. I appreciate everyone's help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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