Expression to calculate % in a report

179 views Asked by At

I am building a report(report server project) using the Data Tools. I have a column Quantity it has a Total. I need another column that calculate the share(%) of each line in the Quantity comparing to the Total.

The expression would be: Line_1_Share = Quantity_of_line_1/Total.

I tried =[Sum(Total/Quantity)] but it does not even accept as a valid expression.

1

There are 1 answers

0
Alan Schofield On BEST ANSWER

If you right-click the textboxes that contain your working 'Quantity' and 'Total' values and look at the expressions you will see the correct format.

For exmaple your 'Quantity' expression might be something like

=Fields!Quantity.Value 

or if it is in a grouped row it might be

=SUM(Fields!Quantity.Value)

your 'Total' expression might also be

=SUM(Fields!Quantity.Value)

When you use SUM() (or any similar aggregate) then the scope of the expression decides what is included in the sum. The scope can be a single row, a row group or an entire dataset. If you do not specify a scope then the position of the textbox determines the scope.

So, if you have a simple table with no grouping other than the total line and your dataset name is dataset1 then your expression would need to be

=Fields!Quantity.Value / SUM(Fields!Quantity.Value, "dataset1")

The above reads .... "For the current row, take the Quantity and divide is but the sum of all Quantities that are within the entire dataset called dataset1"

If this does not help, post your current report design including and row and/or column groups.