简体   繁体   English

嵌套的IF&AND语句Excel

[英]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. 我在使用嵌套的IF&AND语句时遇到了麻烦,我确定问题出在与AND语句有关,因为我的函数格式正确。

I'm looking to Return a string based on the % of a table I have done AD38= 4%,AE38= 12%,AF38= 13%,AG38= 70%* 我希望根据我完成的表的百分比返回字符串AD38 = 4%,AE38 = 12%,AF38 = 13%,AG38 = 70%*

The above are formulas themselves but these are the results. 以上是公式本身,但这是结果。 The IF formula is below. IF公式如下。 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. 嵌套IF确实是一个坏主意。 Lookup formulae (vlookup, hlookup, index/match, etc) are better when the information is structured. 当信息结构化时,查找公式(vlookup,hlookup,索引/匹配等)更好。 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%). 此处, INDEX(AD37:AG37,MATCH(MAX(AD38:AG38),AD38:AG38,0))分为多个部分,最里面的是MAX(AD38:AG38) ,它从您的4个单元格(在您的示例是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). MATCH查找此值的位置(在您的示例中为第4个单元格),将其馈入INDEX以便它返回匹配的单元格(范围为AD37:AG37的第4个单元格)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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