表达式中错位的括号

时间:2015-03-12 20:25:45

标签: visual-studio-2010 ssrs-2008-r2

另一双眼睛看这个会很棒。我得到两个错误消息之一,我越来越混乱。它要么是另一个括号,要么它不是正确使用True / False。我只是有点沮丧地看着它。任何帮助将非常感激。这是漫长的一天。

=IIF((Sum(Fields!January.Value, "CDataSet")- Code.DivideBy(Fields!M191.Value, Sum(Fields!Totals.Value, "DataSet2")) < 0 
and (Sum(Fields!January.Value, "CDataSet")- Code.DivideBy(Fields!M191.Value, Sum(Fields!Totals.Value, "DataSet2")))> Sum(Fields!Variance.Value, "CDataSet")),"Red",
IIF((Sum(Fields!January.Value,"CDataSet")- Code.DivideBy(Fields!M191.Value, Sum(Fields!Totals.Value, "DataSet2"))) > 0 
and (Sum(Fields!January.Value, "CDataSet")- Code.DivideBy(Fields!M191.Value, Sum(Fields!Totals.Value, "DataSet2"))) > Sum(Fields!Variance.Value, "CDataSet")), "LimeGreen","Transparent")

1 个答案:

答案 0 :(得分:1)

当我将代码缩进到括号的级别时,我得到:

=IIF(
  (
    Sum(Fields!January.Value, "CDataSet") - Code.DivideBy(
      Fields!M191.Value, Sum(Fields!Totals.Value, "DataSet2")
    ) < 0 
    and (
      Sum(Fields!January.Value, "CDataSet") - Code.DivideBy(
        Fields!M191.Value, Sum(Fields!Totals.Value, "DataSet2")
      )
    ) > Sum(Fields!ThresholdAging.Value, "CDataSet")
  ),
  "Red",
  IIF(
    (
      Sum(Fields!January.Value,"CDataSet") - Code.DivideBy(
        Fields!M191.Value, Sum(Fields!Totals.Value, "DataSet2")
      )
    ) > 0 
    and (
      Sum(Fields!January.Value, "CDataSet") - Code.DivideBy(
        Fields!M191.Value, Sum(Fields!Totals.Value, "DataSet2")
      )
    ) > Sum(Fields!ThresholdAging.Value, "CDataSet")
  ),
  "LimeGreen",
  "Transparent"
)

结论:内部IIF只有一个参数,外部IIF有五个。我认为你的意思是将最后两个字符串放在内部IIF中:

      ...
    ) > Sum(Fields!ThresholdAging.Value, "CDataSet"),
    "LimeGreen",
    "Transparent"
  )
)