In my Previous Post I explained about the count of rows in a column containing values in it. My next task was to count the no of columns in a row containing values in it and finally summing up the total values. It was like finding the aggregate(sum) of the Aggregate function already used in the Expression.
Firstly I used the Sum function under Aggregate 1 to count the no of columns under each row. The result was as correct as expected. But since I had to find the Sum of the Aggregate 1, I used ReportItems to find the sum like:
but it resulted in the following error:
I then Google out and found a very helpful post on msdn.
- According, I created a Function under Reports Properties.
- Then under First Expression (i.e. Aggregate 1), I used the Custom function which sums up the Total after each row. like:-
=Code.Sum(IIF(IsNothing(Fields!new_Maths.Value), 0, 1) + IIF(IsNothing(Fields!new_English.Value), 0, 1) + IIF(IsNothing(Fields!new_Computer.Value), 0, 1) + IIF(IsNothing(Fields!new_Science.Value), 0, 1)
- Following this in the Second Expression (i.e. Aggregate 2), I just called the Total from my custom code.
Finally I got the correct result:-
Hope this will be helpful.