简体   繁体   中英

Nested IF & AND statement Excel

I'm having trouble with a nested IF & AND statement, I'm sure that the problem is to do with the AND statements because my function is in the correct format.

I'm looking to Return a string based on the % of a table I have done AD38= 4%,AE38= 12%,AF38= 13%,AG38= 70%*

The above are formulas themselves but these are the results. The IF formula is below. I appreciate it's very long but I'm really banging my head against the wall.

IF(AND(AD38>AE38,AD38>AF38,AD38>AG38),CONCATENATE(AX31," customers age ",AD37," are the dominant age group"),

IF(AND(AE38>AD38,AE38>AF38,AF38>AG38),CONCATENATE(AX31," customers age ",AE37," are the dominant age group"),

IF(AND(AF38>AD38,AF38>AE38,AF38>AG38),CONCATENATE(AX31," customers age ",AF37," are the dominant age group"),

IF(AND(AG38>AD38,AG38>AE38,AG38>AG38),CONCATENATE(AX31," customers age ",AG37," are the dominant age group")))))

Any help is reaaaaally appreciated!

It's really a bad idea to nest IF s. Lookup formulae (vlookup, hlookup, index/match, etc) are better when the information is structured. The solution I propose is the following:

=CONCATENATE(AX31," customers age ",INDEX(AD37:AG37,MATCH(MAX(AD38:AG38),AD38:AG38,0))," are the dominant age group")

Here, INDEX(AD37:AG37,MATCH(MAX(AD38:AG38),AD38:AG38,0)) is in multiple parts, the innermost being MAX(AD38:AG38) , which gets the highest value from your 4 cells (in your example, 70%). MATCH looks for the position of this value (in your example, 4th cell), feeds it to INDEX so that it returns the matching cell (4th cell in the range AD37:AG37).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM