【问题标题】:Using nested IF in Google Sheets在 Google 表格中使用嵌套 IF
【发布时间】:2019-11-13 13:18:15
【问题描述】:
我正在尝试在单个单元格中创建多个 IF,因此如果单元格状态为“关键”,则相邻单元格应声明“需要在 24 小时内响应”。如果单元格状态为“中”,则相邻单元格应声明“需要在 48 小时内回复”。如果它声明“低”,那么相邻的应该声明“在其他优先级得到解决后需要响应”......我如何创建该公式?
【问题讨论】:
标签:
if-statement
google-sheets
nested
google-sheets-formula
array-formulas
【解决方案1】:
像这样:
=IF(A1="Critical"; "response required within 24hrs";
IF(A1="Medium"; "response required within 48hrs";
IF(A1="Low"; "response required after other priorites are addresse"; )))
对于这样的数组:
=ARRAYFORMULA(
IF(A1:A10="Critical"; "response required within 24hrs";
IF(A1:A10="Medium"; "response required within 48hrs";
IF(A1:A10="Low"; "response required after other priorites are addresse"; ))))
【解决方案2】:
如果您使用SWITCH 语句而不是多个链接的IFs 会更容易。
通用公式如下:SWITCH(expression, case1, value1, [case2_or_default, …], [value2, …])
因此,对于您的特殊用例,它将如下所示:
=SWITCH([CELL-TO-COMPARE],"Critical","response required within 24hrs","Medium","response required within 48hrs","Low","Response required after other priorites are addresse")
玩得开心,干杯