Excel IF/AND/OR formula support

%3CLINGO-SUB%20id%3D%22lingo-sub-2799766%22%20slang%3D%22en-US%22%3EExcel%20IF%2FAND%2FOR%20formula%20support%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2799766%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%202%20formulas%20that%20I%20need%20help%20with%20-%20For%20this%20first%20formula%2C%20I%20cannot%20get%20the%20field%20to%20give%20me%20data%20for%20all%20names%20and%20levels%20it%20ONLY%20gives%20me%20data%20for%20all%20levels%20of%20Bronze%20but%20not%20the%20others.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3E%3DIF(AND(%24C%2413%3D%22Bronze%22%2C%24D%2416%3D%22Level%201%22)%2CBronze!K15%2CIF(%24D%2416%3D%22Level%202%22%2CBronze!V15%2CIF(%24D%2416%3D%22Level%203%22%2CBronze!AG15%2CIF(%24D%2416%3D%22Level%204%22%2CBronze!AR15%2COR(IF(AND(C13%3D%22Silver%22%2CD16%3D%22Level%201%22)%2CSilver!K15%2CIF(D16%3D%22Level%202%22%2CSilver!V15%2CIF(D16%3D%22Level%203%22%2CSilver!AG15%2CIF(D16%3D%22Level%204%22%2CSilver!AR15%2CIF(AND(C13%3D%E2%80%9DGold%E2%80%9D%2CD16-%22Level%201%22)%2CGold!K15%2CIF(D16%3D%22Level%202%22%2CGold!V15%2CIF(D16%3D%22Level%203%22%2CGold!AG15%2CIF(D16%3D%22Level%204%22%2CGold!AR15%2C%20IF(AND(C13%3D%E2%80%9DPlatinum%E2%80%9D%2CD16-%22Level%201%22)%2CPlatinum!K15%2CIF(D16%3D%22Level%202%22%2CPlatinum!V15%2CIF(D16%3D%22Level%203%22%2CPlatinum!AG15%2CIF(D16%3D%22Level%204%22%2CPlatinum!AR15%2C)))))))))))))))))%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAND%20%23%202%20-%20For%20this%20second%20formula%2C%20I%20get%20no%20data%20at%20all%20coming%20back%20-%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DIF(AND(M16%3DTRUE%2C%24C%2413%3D%22Bronze%22)%2CBronze!H72%2CIF(AND(M16%3DTRUE%2C%24C%2413%3D%22Silver%22)%2CSilver!H72%2CIF(AND(M16%3DTRUE%2C%24C%2413%3D%22Gold%22)%2CGold!H72%2CIF(AND(M16%3DTRUE%2C%24C%2413%3D%22Platinum%22)%2CPlatinum!H72%2C%22%22))))%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2799766%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2799891%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20IF%2FAND%2FOR%20formula%20support%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2799891%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1171414%22%20target%3D%22_blank%22%3E%40tmadaras%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFirst%20formula.%20Logic%20is%20not%20exactly%20clear.%20Your%20formula%3A%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3E%3DIF(AND(%24C%2413%3D%22Bronze%22%2C%24D%2416%3D%22Level%201%22)%2C%20Bronze!K15%2C%0A%20%20IF(%20%24D%2416%3D%22Level%202%22%2C%20Bronze!V15%2C%0A%20%20IF(%20%24D%2416%3D%22Level%203%22%2CBronze!AG15%2C%0A%20%20IF(%20%24D%2416%3D%22Level%204%22%2CBronze!AR15%2C%0A%20%20%20%20%20%20%20OR(%0A%20%20%20%20%20%20%20%20%20%20%20IF(%20AND(%20C13%3D%22Silver%22%2C%20D16%3D%22Level%201%22)%2C%20Silver!K15%2C%0A%20%20%20%20%20%20%20%20%20%20%20IF(%20D16%3D%22Level%202%22%2CSilver!V15%2C%0A%20%20%20%20%20%20%20%20%20%20%20IF(%20D16%3D%22Level%203%22%2CSilver!AG15%2C%0A%20%20%20%20%20%20%20%20%20%20%20IF(%20D16%3D%22Level%204%22%2CSilver!AR15%2C%0A%20%20%20%20%20%20%20%20%20%20%20IF(%20AND(C13%3D%E2%80%9DGold%E2%80%9D%2CD16-%22Level%201%22)%2CGold!K15%2C%0A%20%20%20%20%20%20%20%20%20%20%20IF(%20D16%3D%22Level%202%22%2CGold!V15%2C%0A%20%20%20%20%20%20%20%20%20%20%20IF(%20D16%3D%22Level%203%22%2CGold!AG15%2C%0A%20%20%20%20%20%20%20%20%20%20%20IF(%20D16%3D%22Level%204%22%2CGold!AR15%2C%0A%20%20%20%20%20%20%20%20%20%20%20IF(%20AND(C13%3D%E2%80%9DPlatinum%E2%80%9D%2CD16-%22Level%201%22)%2CPlatinum!K15%2C%0A%20%20%20%20%20%20%20%20%20%20%20IF(%20D16%3D%22Level%202%22%2CPlatinum!V15%2C%0A%20%20%20%20%20%20%20%20%20%20%20IF(%20D16%3D%22Level%203%22%2CPlatinum!AG15%2C%0A%20%20%20%20%20%20%20%20%20%20%20IF(%20D16%3D%22Level%204%22%2CPlatinum!AR15%2C))))))))))))%0A%20%20%20%20%20%20)%0A))))%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EPerhaps%20you%20mean%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3E%3DIF(%20%24C%2413%3D%22Bronze%22%2C%0A%20%20%20%20IF(%20%24D%2416%3D%22Level%201%22%2C%20Bronze!K15%2C%0A%20%20%20%20IF(%20%24D%2416%3D%22Level%202%22%2C%20Bronze!V15%2C%0A%20%20%20%20IF(%20%24D%2416%3D%22Level%203%22%2CBronze!AG15%2C%0A%20%20%20%20IF(%20%24D%2416%3D%22Level%204%22%2CBronze!AR15%2C%20%22nothing%22))))%2C%0A%0A%20%20IF(%20C13%3D%22Silver%22%2C%0A%20%20IF(%20D16%3D%22Level%201%22%2C%20Silver!K15%2C%0A%20%20IF(%20D16%3D%22Level%202%22%2CSilver!V15%2C%0A%20%20IF(%20D16%3D%22Level%203%22%2CSilver!AG15%2C%0A%20%20IF(%20D16%3D%22Level%204%22%2CSilver!AR15%2C%20%20%22nothing%22))))%2C%0A%0A%20%20IF(%20C13%3D%22Gold%22%2C%0A%20%20IF(%20D16%3D%22Level%201%22%2CGold!K15%2C%0A%20%20IF(%20D16%3D%22Level%202%22%2CGold!V15%2C%0A%20%20IF(%20D16%3D%22Level%203%22%2CGold!AG15%2C%0A%20%20IF(%20D16%3D%22Level%204%22%2CGold!AR15%2C%20%20%22nothing%22))))%2C%0A%0A%20%20IF(%20C13%3D%22Platinum%22%2C%0A%20%20IF(%20D16-%22Level%201%22%2C%20Platinum!K15%2C%0A%20%20IF(%20D16%3D%22Level%202%22%2CPlatinum!V15%2C%0A%20%20IF(%20D16%3D%22Level%203%22%2CPlatinum!AG15%2C%0A%20%20IF(%20D16%3D%22Level%204%22%2CPlatinum!AR15%2C%20%22nothing%22))))%0A%0A))))%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EThat%20is%20here%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20467px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F313988i2CC18BC8CF882952%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2799934%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20IF%2FAND%2FOR%20formula%20support%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2799934%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1171414%22%20target%3D%22_blank%22%3E%40tmadaras%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESecond%20formula%20-%20you%20shall%20to%20check%20R16%2C%20not%20M16%3A%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3E%3DIF(%20AND(R16%3DTRUE%2C%24C%2413%3D%22Bronze%22)%2CBronze!H72%2C%0A%20%20IF(%20AND(R16%3DTRUE%2C%24C%2413%3D%22Silver%22)%2CSilver!H72%2C%0A%20%20IF(%20AND(R16%3DTRUE%2C%24C%2413%3D%22Gold%22)%2CGold!H72%2C%0A%20%20IF(%20AND(R16%3DTRUE%2C%24C%2413%3D%22Platinum%22)%2CPlatinum!H72%2C%22%22%0A))))%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Eor%20to%20simplify%20a%20bit%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3E%3DIF(%20R16%2C%0A%20%20%20%20%20IF(%20%24C%2413%3D%22Bronze%22%2CBronze!H72%2C%0A%20%20%20%20%20IF(%20%24C%2413%3D%22Silver%22%2CSilver!H72%2C%0A%20%20%20%20%20IF(%20%24C%2413%3D%22Gold%22%2CGold!H72%2C%0A%20%20%20%20%20IF(%20%24C%2413%3D%22Platinum%22%2CPlatinum!H72%2C%22%22%0A))))%20)%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2799937%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20IF%2FAND%2FOR%20formula%20support%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2799937%22%20slang%3D%22en-US%22%3EThank%20you%20but%20now%20it%20is%20changing%20every%20field%20and%20not%20individual%20fields%20-%20so%20if%20I%20change%20the%20level%20in%20D16%20then%20all%20Fields%20Under%20cost%20are%20exactly%20the%20same%20and%20change%20together.%20I%20am%20trying%20to%20get%20it%20to%20where%20each%20field%20under%20level%20of%20effort%20will%20change%20the%20specific%20cost%20under%20the%20Cost%20field%20corresponding%20to%20the%20level%20of%20effort%20in%20the%20same%20row.%3C%2FLINGO-BODY%3E
New Contributor

I have 2 formulas that I need help with - For this first formula, I cannot get the field to give me data for all names and levels it ONLY gives me data for all levels of Bronze but not the others. 

 

=IF(AND($C$13="Bronze",$D$16="Level 1"),Bronze!K15,IF($D$16="Level 2",Bronze!V15,IF($D$16="Level 3",Bronze!AG15,IF($D$16="Level 4",Bronze!AR15,OR(IF(AND(C13="Silver",D16="Level 1"),Silver!K15,IF(D16="Level 2",Silver!V15,IF(D16="Level 3",Silver!AG15,IF(D16="Level 4",Silver!AR15,IF(AND(C13=”Gold”,D16-"Level 1"),Gold!K15,IF(D16="Level 2",Gold!V15,IF(D16="Level 3",Gold!AG15,IF(D16="Level 4",Gold!AR15, IF(AND(C13=”Platinum”,D16-"Level 1"),Platinum!K15,IF(D16="Level 2",Platinum!V15,IF(D16="Level 3",Platinum!AG15,IF(D16="Level 4",Platinum!AR15,)))))))))))))))))

 

AND # 2 - For this second formula, I get no data at all coming back -

 

=IF(AND(M16=TRUE,$C$13="Bronze"),Bronze!H72,IF(AND(M16=TRUE,$C$13="Silver"),Silver!H72,IF(AND(M16=TRUE,$C$13="Gold"),Gold!H72,IF(AND(M16=TRUE,$C$13="Platinum"),Platinum!H72,""))))

 

8 Replies

@tmadaras 

First formula. Logic is not exactly clear. Your formula:

=IF(AND($C$13="Bronze",$D$16="Level 1"), Bronze!K15,
  IF( $D$16="Level 2", Bronze!V15,
  IF( $D$16="Level 3",Bronze!AG15,
  IF( $D$16="Level 4",Bronze!AR15,
       OR(
           IF( AND( C13="Silver", D16="Level 1"), Silver!K15,
           IF( D16="Level 2",Silver!V15,
           IF( D16="Level 3",Silver!AG15,
           IF( D16="Level 4",Silver!AR15,
           IF( AND(C13=”Gold”,D16-"Level 1"),Gold!K15,
           IF( D16="Level 2",Gold!V15,
           IF( D16="Level 3",Gold!AG15,
           IF( D16="Level 4",Gold!AR15,
           IF( AND(C13=”Platinum”,D16-"Level 1"),Platinum!K15,
           IF( D16="Level 2",Platinum!V15,
           IF( D16="Level 3",Platinum!AG15,
           IF( D16="Level 4",Platinum!AR15,))))))))))))
      )
))))

Perhaps you mean

=IF( $C$13="Bronze",
    IF( $D$16="Level 1", Bronze!K15,
    IF( $D$16="Level 2", Bronze!V15,
    IF( $D$16="Level 3",Bronze!AG15,
    IF( $D$16="Level 4",Bronze!AR15, "nothing")))),

  IF( C13="Silver",
  IF( D16="Level 1", Silver!K15,
  IF( D16="Level 2",Silver!V15,
  IF( D16="Level 3",Silver!AG15,
  IF( D16="Level 4",Silver!AR15,  "nothing")))),

  IF( C13="Gold",
  IF( D16="Level 1",Gold!K15,
  IF( D16="Level 2",Gold!V15,
  IF( D16="Level 3",Gold!AG15,
  IF( D16="Level 4",Gold!AR15,  "nothing")))),

  IF( C13="Platinum",
  IF( D16-"Level 1", Platinum!K15,
  IF( D16="Level 2",Platinum!V15,
  IF( D16="Level 3",Platinum!AG15,
  IF( D16="Level 4",Platinum!AR15, "nothing"))))

))))

That is here:

image.png

@tmadaras 

Second formula - you shall to check R16, not M16:

=IF( AND(R16=TRUE,$C$13="Bronze"),Bronze!H72,
  IF( AND(R16=TRUE,$C$13="Silver"),Silver!H72,
  IF( AND(R16=TRUE,$C$13="Gold"),Gold!H72,
  IF( AND(R16=TRUE,$C$13="Platinum"),Platinum!H72,""
))))

or to simplify a bit

=IF( R16,
     IF( $C$13="Bronze",Bronze!H72,
     IF( $C$13="Silver",Silver!H72,
     IF( $C$13="Gold",Gold!H72,
     IF( $C$13="Platinum",Platinum!H72,""
)))) )
Thank you but now it is changing every field and not individual fields - so if I change the level in D16 then all Fields Under cost are exactly the same and change together. I am trying to get it to where each field under level of effort will change the specific cost under the Cost field corresponding to the level of effort in the same row.

@tmadaras 

Just in case, second formula could be

=IF( R16, INDIRECT( $C$13 & "!H72" ), "")

@tmadaras 

 

Are you in any way open to rethinking how your spreadsheet is organized? That level of nested IFs is almost a case-study in the kind of formulas that most Excel texts advise NOT doing. Why? Well, you're experiencing the "why"--such formulas, with levels of conditionals going so deep, very quickly become unintelligible and unmanageable.

 

The reality is that using one of the many LOOKUP functions (VLOOKUP, XLOOKUP), or related capabilities (such as INDEX and MATCH) or even the more recent FILTER--using one of those with a well designed table could serve the same purpose while also being far more maintainable, far more flexible, far more--well, a whole host of positives.

 

It would require re-organizing the data on those bronze, silver, gold and platinum into a single table, and that would be some work, but the result would be far more accessible to Excel. You've clearly created those sheets for human consumption, but in the process have gotten in the way of using Excel cleanly.

 

Hence the question: are you open to re-thinking your approach?

@mathetes - I am definitely open to rethinking the spreadsheet - I am a novice at Excel and I am learning. I do like the suggestion - do you have an example of what you are suggesting I could look at and I will take a stab at it. Thank you.

@tmadaras 

I changed formula only in this very cell

image.png

and didn't change the rest. That's only reverse engineering of your initial formula, have no idea what is the business logic behind.

@tmadaras 

 

I've attached an example created simply as a demonstration--it does use the LET function which is very new, so you'll need to have the most recent version of Excel to make it work. If it doesn't work for you, please let me know and I'll find another example.

 

This example calculates US income tax, and is somewhat comparable to your situation in that I actually have multiple tables underneath the central formula--one table for each of the different tax filing statuses possible--and all it is doing is a single calculation based on a single input, but it uses the VLOOKUP function to access the appropriate row of the appropriate table.

 

Beyond that, or maybe BEFORE that, since you are a beginner in Excel, it might be helpful if first you just look at a basic primer on tables and VLOOKUP. Here are some links that could be helpful in that foundational learning: 

Tables: https://exceljet.net/excel-tables

VLOOKUP: https://exceljet.net/excel-functions/excel-vlookup-function