I have a ssrs report. There is a matrix with 2 row groups(from outer to inner): group – item, and 1 column group: year. I hope it’s fairly easy to understand. Please refer to below “image”.
Group CAGR 2010 2011
Group1 CAGR_group1 sum_group1_2010 sum_group1_2011
Item1 CAGR_item1 sum_item1_2010 sum_item1_2011
Item2 CAGR_item2 sum_item2_2010 sum_item2_2011
The sum_group1_2010 and sum_group1_2011 are sum of item1 and item2 for each year.
CAGR_item1 and CAGR_item2 are calculated by this fomular:
CAGR = (sum_item2_2011/sum_item2_2010)^(1/n) - 1 (n=2011-2010)
I created this function in code. It’s simple to calculate CAGR for each item. I used following expression: note First refer to 2010, and last refer to 2011 in this case.
Code.CAGR(First(Fields!Amount.Value).ToString, Last(Fields!Amount.Value).ToString, Last(Fields!year.Value).ToString - First(Fields!year.Value).ToString)
Now the problem is how can I calculate for the CAGR_group1? I intended to use
Code.CAGR(First(Sum(Fields!Amount.Value)).ToString, Last(Sum(Fields!Amount.Value)).ToString, Last(Fields!year.Value).ToString - First(Fields!year.Value).ToString).
Then SSRS reported can not use aggregate function in another aggregate function.
Hope it’s all clear. Thanks.
I think the easiest way to do this would be to add the calculation to your SQL query: it could be a new column in your existing query, which calculates to the same value for every record(row). Then in your report just use the FIRST function.
Alternately, this may work if you add appropriate scope statements to your aggregate functions, such as FIRST(SUM(Fields!Amount.Value, “ItemGroupName”) , “Group1GroupName”)