IFAND公式中的参数消息太多 - 跟进

时间:2016-05-18 16:42:55

标签: excel-formula

这是来自excel-2013-too-many-arguments-message-to-ifand-formula

的第二个跟进问题

你好 -

我仍在处理我的决定表并遇到另一个问题。这是我的公式:

=+IF($J7="Planned - Shift / Vacation Coverage",IF(O7="No","Is Helper out during day shift?","Is an Eng out during day shift?"),
IF($J7="Planned - Off-shift PMs",IF(O7="No","Schedules OT - STOP","LE schedules work within shift - STOP"),
IF($J7="Planned - Training",IF(O7="No","Schedules training during shift - STOP","Schedules OT - STOP"),
IF($J7="Unplanned - Sick call in",IF(O7="No","Is Helper out during day shift?","Is an Eng out during day shift?"),
IF($J7="Unplanned - Emergency response/repair", IF(N7="Can this be handled by scheduled resources within shift?", IF(O7="No","Is the request a code 2?","Work is executed within shift - STOP"), IF(N7="Is the request a code 3?", IF(O7="No", "Schedules OT - STOP","Can this be handled by scheduled resources within shift?"),
IF($J7="Unplanned - Weather",IF(N7="Can resources be allocated from the shift in the first instance?",IF(O7="No","Schedules OT - STOP","CE assigns work to LE - STOP"), IF(N7="Can CE or ACE become the additional HC?",IF(O7="No","Schedules OT - STOP","CE or ACE covers shift - STOP")))))))))))

我得到了每种OT类型的预期结果,但最后一种 - “Unplanned - Weather”除外。它是一个二进制IF公式,类似于上面的“计划外 - 紧急响应/修复”,但由于某种原因,这个是有效的,但前者不是。我得到一个" FALSE"两个回复的输出。

2 个答案:

答案 0 :(得分:0)

=IF($J7="Unplanned - Weather", IF(N7="Can resources be allocated from the shift in the first instance?", IF(O7="No","Schedules OT - STOP","CE assigns work to LE - STOP"), IF(N7="Can CE or ACE become the additional HC?", IF(O7="No","Schedules OT - STOP","CE or ACE covers shift - STOP"))))

让我们来看看当J7等于Unplanned -Weather时会发生什么?这意味着我们的第一个if语句是真的。我们继续:

IF(N7="Can resources be allocated from the shift in the first instance?", IF(O7="No","Schedules OT - STOP","CE assigns work to LE - STOP"), IF(N7="Can CE or ACE become the additional HC?", IF(O7="No","Schedules OT - STOP","CE or ACE covers shift - STOP")))

注意到如果J7不等于计划外 - 天气,那么我们还没有告诉if语句该做什么。如果J7等于STACK会发生什么。由于您没有为J7检查提供错误结果,因此默认情况下它将返回false。

现在回到J7检查结果出现的情况,我们正在处理N7检查。假设N7等于QBERT。因此,第一次N7检查是错误的,我们现在正在查看:

IF(N7="Can CE or ACE become the additional HC?", IF(O7="No","Schedules OT - STOP","CE or ACE covers shift - STOP"))

N7仍然等于QBERT,因此N7检查再次为假,这意味着......嘿,没有选项可以检查N7,这意味着默认情况下Excel将返回False。为什么我们不要在错误捕获声明中告诉她让我们没有N7的问题。所以最后一个公式变为:

IF(N7="Can CE or ACE become the additional HC?", IF(O7="No","Schedules OT - STOP","CE or ACE covers shift - STOP"),"N7 check is FALSE")

因此,如果我们将所有内容反馈到原始等式中并添加错误检查,以确定J7何时失败,那么我们应该结束如下:

=IF($J7="Unplanned - Weather",IF(N7="Can resources be allocated from the shift in the first instance?",IF(O7="No","Schedules OT - STOP","CE assigns work to LE - STOP"), IF(N7="Can CE or ACE become the additional HC?",IF(O7="No","Schedules OT - STOP","CE or ACE covers shift - STOP"),"N7 is False")),"J7 is Flase")

查看该部分是否可以帮助您找出问题所在。请记住,当J7应该等于计划外 - 天气而不是当J7是您计划的其他J7值之一时,这只是看问题。

答案 1 :(得分:0)

在这种深度的IF条件下工作是可能的,但通常是不切实际的。你可能想重新考虑你的结构。

一种方法是建立一个条件表,列出所有可能的条件,如下表所示。 “连接条件”列用于将条件“J”,“N”和“O”连接为由“|”分隔的文本。最后一列是您要返回的映射结果。

('加入条件'列的行为就好像它是AND运算符,公式为=CONCATENATE([@[Condition "J"]],"|",[@[Condition "N"]],"|",[@[Condition "O"]]))。

enter image description here

然后在主数据表中,简单应用VLOOKUP,如下所示:

enter image description here

这保持公式简短易维护。对于条件表,您可以轻松控制将来如何更改结果。平均时间,添加和删除结果也会更容易。