Friday, March 9, 2012

How to sub total a calculated column?

In my report body, there is table, which contains a column displaying calculated data based on a field from a dataset. The expression for the cell called "calculatedCost" below this column is :

"=Iif(Fields!Facotr.Value=0, Fields!cost.Value * Fields!Quantity.Value *1,Fields!cost.Value * Fields!Quantity.Value *Fields!Factor.Value)

The data row in the table will be grouped by fields called Code like "A", "B" and etc. Now I need to sub total the above calculated column under each group, i.e. Subtotals for Code A and Code B. How can I do this? I tried the following expression:

=Sum(ReportItems("calculatedCost").Value)

But I got an error saying that Aggregate functions couldn't be used in report body. Then how can I refer the value of cell "calculatedCost"? Any suggestion will be highly appreciated..

You could perform the calculation in your dataset and not display that field.

SELECT *, (<Expression HERE>) As CalcField FROM Query

Then use that field in the summary field.

=SUM(Fields!CalcField.Value)

|||Thanks a lot. I got it work!

No comments:

Post a Comment