简体   繁体   English

一个Excel公式中包含多个IF

[英]Multiple IFs in one excel formula

I have created this formula but it's giving me a #VALUE! 我已经创建了这个公式,但是它给了我#VALUE! error. 错误。 Can someone help to see what is wrong? 有人可以帮忙看看有什么问题吗? Thank you. 谢谢。

=IF(A2="","",IF(AND(C2="Female",OR(E2="Black")),((141*(POWER(MIN(A2/0.7,1),-0.329))*POWER(MAX(A2/0.7,1),-1.209)*POWER(0.993,F2)*1.018*1.159)),((141*(POWER(MIN(A2/0.7,1),-0.411))*POWER(MAX(A2/0.7,1),-1.209)*POWER(0.993,F2)*1.018)))),IF(AND(C2="Male",OR(E2="Black")),((141*(POWER(MIN(A2/0.9,1),-0.329))*POWER(MAX(A2/0.9,1),-1.209)*POWER(0.993,F2)*1.159)),((141*(POWER(MIN(A2/0.9,1),-0.411))*POWER(MAX(A2/0.9,1),-1.209)*POWER(0.993,F2))))

You have two IF statements in one cell, separated by a comma. 一个单元格中有两个IF语句,以逗号分隔。 Check the brackets. 检查括号。

The first IF has a nested IF with Female and black, which has a calculation in the TRUE part and another calculation in the FALSE part. 第一个IF有一个带母和黑色的嵌套IF,在TRUE部分有一个计算,在FALSE部分有另一个计算。 The nested IFs are closed correctly. 嵌套的IF已正确关闭。

Then follows a comma and and IF with Male and Black, with a calculation in the TRUE and another calculation in the FALSE part. 然后用逗号和和IF加上Male和Black,在TRUE中计算,在FALSE部分中计算。

You need to check your syntax. 您需要检查语法。 You can't have two IFs in one cell like that. 像这样一个单元格不能有两个IF。 Excel does not work like that. Excel不能那样工作。

I cannot comment so please let me put it here. 我无法发表评论,所以请允许我将其放在此处。

To help you with your code, please check the following tips: 为了帮助您编写代码,请检查以下提示:

  1. Put ALL your formulae as text in notepad or textbox. 将所有公式作为文本放在记事本或文本框中。 do not use "=" yet. 请勿使用“ =“。 You may try to use the equal sign to see if your formula is working well. 您可以尝试使用等号来查看您的公式是否运行良好。 but you have to remove them afterwards . 但是您之后必须删除它们 You can enclose them in parenthesis if it suits you. 如果适合,可以将它们括在括号中。

Eg 例如

141*(POWER(MIN(A2/0.7,1),-0.329)) 141 *(POWER(MIN(A2 / 0.7,1), - 0.329))

into

(141*(POWER(MIN(A2/0.7,1),-0.329))) (141 *(POWER(MIN(A2 / 0.7,1), - 0.329)))

that means it is a single item in your nested function. 这意味着它只是嵌套函数中的一个项目。

  1. if you do nested if functions, finish the parenthesis first, then the commas before filling the slots with formulas you have. 如果您嵌套了if函数,请先使用括号,然后使用逗号,然后再使用您拥有的公式填充广告位。

Eg 例如

= if ( , , ) =如果(,,)

or 要么

= if ( , ,if( , , if( , , ))) = if(,,if(,,if(,,)))

Note: A single parenthesis will ruin your formula so I do this to eliminate this possibility 注意:单个括号会破坏您的公式,因此我这样做是为了消除这种可能性

  1. Fill your main if function with the formula. 用公式填充您的main if函数。 Copy and paste as is. 照原样复制和粘贴。

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

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