Summarizing an Expression Column in SSRS

The detail row in my table contains a column with the expression:
= sum (Fields! one.Value) / sum (Fields! two.Value)

I want to summarize this column, but the results that I get are not the sum of the coefficients, but the ratio of the sums. For instance:

  sum (Fields! one.Value) sum (Fields! two.Value) ratio
               3 6 0.5 
               3 6 0.5 
 total: 6 12 0.5

I would like the value in the lower right corner to be the sum of the values ​​above it (i.e. 1.0), rather than the ratio of the values ​​to the left of it. I tried to calculate the amount as:
amount (amount (Fields! one.Value) / amount (Fields! two.Value)),
but it also gives a 0.5 response.

Does anyone have any ideas?


[This did not allow me to publish my own answer within 24 hours, and so here:]

Ok, I figured out how to do this. I added another column to the right of the relation column and set its visibility to “invisible”. In the details bar, I added this expression:
= runningValue (sum (fields! one. value) / sum (fields, two. value), sum, "table1_grp")
(table1_grp is the group it was in). Then, in a common row in the relationship column, I simply copied the value from the runningValue text box. In other words, the expression was:
= ReportItems! Textbox55.Value
So the current amount is invisible in the table, but I use the last value in the total row.

And it took me only 3 days to figure this out. Phew!


UPDATE:

I showed the problem and the “solution” to a colleague, and he had a much more elegant solution:

In the Total Volume field, use the following expression:

= sum (sum (Fields! one.Value, "table1_grp") / sum (Fields! two.Value, "table1_grp"))

Basically, adding an area to internal amounts does the trick.

+7
source share
2 answers

Try Sum ((fields! One.Value / Fields! Two.Value)).

0
source

You can also add a calculated field to your dataset, which creates a relation. Add this data field instead of the expression directly to the field. Then you can get its total value by right-clicking and choosing add general

Right-click on your dataset, select "Add Calculated Field", specify its ratio, add your expression here. Then Ratio will be a choice that you can add to the table as an actual field instead of an expression, and then you can sum it up. Hope this makes sense.

0
source

Source: https://habr.com/ru/post/886315/


All Articles