SSRS Summation of Top 5 Rows in Tablix
Hi,
I have created Tablix with 14 columns and works fine as expected. However my requirement is, above the Column Fields i need to display the sum for each column which also works fine for me. Above the sum of each column I need to add top 5 values for each
column where it is not working as expected. I tried with Groups and runningvalue and custom code, however no luck, I presume that only first value of the column is displaying and next values are not adding. Please someone can shed some light on this.
6127
4
4
5
7
4
4
3
5
452
3
96
6366
18
19
16
14
4
6
14
12
452
15
100
Days
Col1
Col2
Col3
Col4
Col5
Col6
Col7
Col8
Col9
Col10
Col11
Col12
1
2419
2
0
0
0
0
0
0
0
0
0
44
2
2263
1
2
2
3
0
0
3
0
4
0
44
3
1131
1
2
3
0
4
4
0
3
444
3
4
4
314
0
0
0
4
0
0
0
2
4
0
4
5
133
1
2
3
0
0
2
11
1
0
3
0
6
59
0
0
4
4
0
0
0
0
0
3
4
7
22
1
4
4
3
0
0
0
3
0
3
0
8
12
8
4
0
0
0
0
0
0
0
0
0
9
13
4
5
0
0
0
0
0
3
0
3
0
Thanks,
NandaNanda
January 22nd, 2011 4:32am
Hi Nanda,
It is really a tough problem. It seems that there is no built-in function to achieve this calculation. If you have to do it, i would suggest you utilize SUBREPORTS. In your situation, you need to new 13 subreports to get the sum of each column's Top
5 values, then in the sum row cell, insert a subreport to reference each Subreports. The dataset query of the subreprots might be like this:
with CTE (Amount, Num) as
(
select amount,ROW_NUMBER() over(order by amount desc) as num from yourTable
)
select SUM(Amount) as Top5Amount from CTE where Num <= 5
thanks,
Jerry
Free Windows Admin Tool Kit Click here and download it now
January 26th, 2011 1:07am