想要添加“和”if或切换

时间:2014-02-26 21:13:39

标签: reporting-services nested switch-statement iif

当我使用此声明时:

=IIF(Sum(Fields!SavingsGoal.Value, "Project_Details") <= Sum(FieldsImplementedSavings.Value, "dsInitiatives") 0,
Sum(Fields!SavingsGoal.Value, "Project_Details") - Sum(Fields!ImplementedSavings.Value, "dsInitiatives"))

然而,当我添加“AND”

=IIF(Sum(Fields!SavingsGoal.Value, "Project_Details") <= Sum(Fields!ImplementedSavings.Value, "dsInitiatives") AND (Fields!GoalType.Value, "Project_Details") = "Implemented",0,
Sum(Fields!SavingsGoal.Value, "Project_Details") - Sum(Fields!ImplementedSavings.Value, "dsInitiatives"))

我收到此错误:

  

警告1 [rsRuntimeErrorInExpression]的值表达式   textrun'textbox58.Paragraphs [0] .TextRuns [0]'包含错误:   参数'VarExpr'不是有效值。

我对SSRS非常陌生,我一直在为同一个问题工作三天,并且正式失去理智。其他搜索让我接近我的答案,但没有雪茄。一旦我得到这个作品,我需要在GoalType为“可执行”时添加它 - 加上我将需要为SavingsGoal&gt;做额外的IIF。已实施保存或可实施。请在答案中帮助和说普通英语。我不是一个受过正式训练的开发人员,编程术语有时让我困惑。我也尝试过切换,结果相同。我确定这是一个疯狂的语法问题,但我发誓我已经尝试了20种方法来进行星期日,并且不能让它发挥作用。

1 个答案:

答案 0 :(得分:1)

问题不在于AND,而是在所有情况下都使用聚合,除了要添加的新条件。尝试将First用于表达式:

=IIF(Sum(Fields!SavingsGoal.Value, "Project_Details") <= Sum(Fields!ImplementedSavings.Value, "dsInitiatives") 
AND First(Fields!GoalType.Value, "Project_Details") = "Implemented", 0,
Sum(Fields!SavingsGoal.Value, "Project_Details") - Sum(Fields!ImplementedSavings.Value, "dsInitiatives"))