سؤال

I'm building a report where I'm trying to write an expression for a variable (not parameter). I'm planning on creating multiple variables, each referencing the SUM(SUM()) of amounts from different datasets. I'm then planning on referencing each of these variables in a single textbox to do a calculation. This is to circumvent SSRS' limitation of using multiple datasets in a single tablix/matrix.

I need some assistance with the syntax. When I use SUM by itself, the report runs fine and I can perform calculations on these values without issues. For example, this works fine:

Variable1:

=SUM(Fields!Amount.Value, "DataSet1")

Variable2:

=SUM(Fields!Amount.Value, "DataSet2")

Textbox1:

=Variable1.Value - Variable2.Value

But I get an error when trying to amend it to the following (which is what I actually need):

Variable1:

=SUM(SUM(Fields!Amount.Value, "DataSet1"))

I get an error saying "The variable expression for the report 'body' uses an aggregate expression without a scope. A scope is required for all aggregates used outside of a data region unless the report contains exactly one dataset." I have a hunch that there's a problem with my syntax/parantheses placement. I tried adding ",DataSet1" again, at the end (SUM(SUM(Fields!Amount.Value, "DataSet1"),"DataSet1") but receive an error about recursive nesting problems. Any suggestions?

هل كانت مفيدة؟

المحلول

I'm guessing where you assign the variable, it doesn't have the concept of these column groups, so the only option is to sum the entire dataset.

I think you can try one of the following:

  1. Assign the value from within the tablix (if it lets you, you might need custom code which aggregates and then sets the variable)
  2. Specify the grouping condition again in a conditional sum, like SUM(IIF(Fields!Location.Value = TheLocationValueForTheColumnYouNeed, Fields!Amount.Value, 0))
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top