如果使用AND,则在Excel中使用

时间:2016-09-21 11:57:24

标签: excel excel-formula

我有以下格式的excel数据:

severity    Type    Overview    Classification  Result
critical    defect  closed      Fix             Good
serious     enhance no change   no fix          Low
Medium      defect  no change   no fix          Low
Low         enhance closed      fix             Poor
critical    defect  Duplicate   fix             Good
Medium      defect  Duplicate   fix             Low
Low         defect  Duplicate                   Poor

我已经编写了计算结果的公式,但由于我对excel的不了解,我无法执行。任何帮助将不胜感激。

以下是条件:

 Severity           Type               Overview     Classifcation       Result
Citical/Serious     Defect/Enhance      Closed          Fix                 Good
                    Defect/Enhance      Closed          No fix              Poor
                    Defect/Enhance      Closed          Updated             Low
                    Defect/Enhance      Duplicate       No fix              poor


Medium/low          Defect/Enhance      closed          No fix              Low
                    Defect/Enhance      Duplicate       No fix              Poor

2 个答案:

答案 0 :(得分:1)

这不好,但是上一个表中定义的条件的解决方案是这样的:

=IF(AND(OR(A2="Critical";A2="Serious");C2="Closed";D2="Fix");"Good";IF(AND(OR(A2="Critical";A2="Serious");C2="Closed";D2="No fix");"Poor";IF(AND(OR(A2="Critical";A2="Serious");C2="Closed";D2="Updated");"Low";IF(AND(OR(A2="Critical";A2="Serious");C2="Duplicate";D2="No fix");"Poor";IF(AND(OR(A2="Medium";A2="Low");C2="Closed";D2="No fix");"Low";IF(AND(OR(A2="Medium";A2="Low");C2="Duplicate";D2="No fix");"Poor";"Undefined"))))))

以更具可读性的多线方式编写(我不确定这将在复制和粘贴中存活):

=IF(AND(OR(A2="Critical";A2="Serious");C2="Closed";D2="Fix");"Good";
   IF(AND(OR(A2="Critical";A2="Serious");C2="Closed";D2="No fix");"Poor";
     IF(AND(OR(A2="Critical";A2="Serious");C2="Closed";D2="Updated");"Low";
       IF(AND(OR(A2="Critical";A2="Serious");C2="Duplicate";D2="No fix");"Poor";
         IF(AND(OR(A2="Medium";A2="Low");C2="Closed";D2="No fix");"Low";
           IF(AND(OR(A2="Medium";A2="Low");C2="Duplicate";D2="No fix");"Poor";
             "Undefined"
           )
         )
       )
     )
   )
 )

如您所见,您未涵盖的任何组合都会产生"Undefined"。你可能会结合一些条件,但这不一定更具可读性。

niced解决方案可能是一个单独的工作表中的完整查找表,其中包含CHOOSE()和VLOOKUP()......

答案 1 :(得分:1)

假设您的数据在范围A1:D8中,您的第一行是标题。 你可以使用这个(丑陋的)公式,它完全按照你在条件表中描述的那样:

=IF(AND(OR(A2="Critical",A2="Serious"),OR(B2="Defect",B2="Enhance")),IF(C2="closed",IF(D2="Fix","Good",IF(D2="No fix","Poor",IF(D2="Updated","Low"))),IF(AND(C2="Duplicate",D2="No"),"poor","No match")),
IF(AND(OR(A2="Medium",A2="Low"),OR(B2="Defect",B2="Enhance")),IF(AND(C2="closed",D2="No fix"),"Low","No match"),IF(AND(C2="duplicate",D2="No fix"),"Poor")))

诀窍是使用else条件作为elseif ..当你有很多时,它很难读。