user3357798
user3357798

Reputation: 1

Want to add "and" to if or switch

When I use this statement:

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

However when I add an "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"))

I get this error:

Warning 1 [rsRuntimeErrorInExpression] The Value expression for the textrun ‘textbox58.Paragraphs[0].TextRuns[0]’ contains an error: Argument 'VarExpr' is not a valid value.

I am extremely new to SSRS, I've been working on this same issue for THREE DAYS and have officially lost my mind. Other searches get me close to my answer but no cigar. Once I get this piece working, I will need to add to it for when the GoalType is "Implementable" - PLUS I will need to do addition IIFs for when the SavingsGoal > ImplementedSavings or Implementable. PLEASE help and speak common English in your answers. I'm not a formally trained developer and programming terms confuse me sometimes. I've tried switch as well, same result. I'm sure it's some crazy syntax issue, but I swear I've tried 20 ways to Sunday and cannot get this to work.

Upvotes: 0

Views: 401

Answers (1)

Chris Latta
Chris Latta

Reputation: 20560

The problem is not the AND, it is that you are using aggregation in all cases except for the new condition you are adding. Try using First to your expression:

=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"))

Upvotes: 1

Related Questions