如果一个条件为真,或者两个不同,则比较两列在Excel中条件为false

时间:2016-10-05 16:11:38

标签: excel-formula

我正试图在excel中确定这个公式,但我一定做错了。我不是程序员,但这是逻辑。这是我现在的公式:=IF(L30="N",IF(G30>F30,"Overspend","Underspend"),IF(G30>E30,"Overspend","Underspend"))

If K2 = "False"     
    If G2>F2    
      return overspend  
   Else  
      return underspend  
Else  
   If G2>E2  
      return overspend  
   Else  
      return underspend  

1 个答案:

答案 0 :(得分:0)

OR()AND()是很棒的功能。

=IF(OR(AND(K2="N",G2>F2),AND(K2="Y",G2>E2)),"Overspend","Underspend")

=IF(                   -- If
   OR(                 -- either
    AND(K2="N",G2>F2), -- all of this 
    AND(K2="Y",G2>E2)  -- or all of this
   )                   -- is true
   ,"Overspend"        -- show this
   ,"Underspend")      -- otherwise show this