SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Get AVERAGE of column data in Reporting Services matrix.


Get AVERAGE of column data in Reporting Services matrix.

Author
Message
Lrobinson 93181
Lrobinson 93181
Valued Member
Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)

Group: General Forum Members
Points: 65 Visits: 140
I need to create an AVG based on the cell data in row_group1 and the number of months that have data. I have the sum of row_group1, but cannot get a count on number of months, and just entering an AVG function in the total column does not produce the correct results.

I have two row groups, and a single column group on "Month" that produces row data by "monthname".

I can get the SUM of my CountDistinct(Fields!CustID.Value), so if I can get the count of the number of "Months" produced by my column group I could calculate my own average, but I cannot get the correct count of months using InScope, (returns all 0's):

=Iif(InScope("MTH"),(CountDistinct(Fields!CustID.Value)), 0)

Basic structure of matrix:

Service Feb Mar Apr AVG # of Distinct Customers per Month
Cleaning 3 7 2 4
TaylorMade
TaylorMade
Mr or Mrs. 500
Mr or Mrs. 500 (508 reputation)Mr or Mrs. 500 (508 reputation)Mr or Mrs. 500 (508 reputation)Mr or Mrs. 500 (508 reputation)Mr or Mrs. 500 (508 reputation)Mr or Mrs. 500 (508 reputation)Mr or Mrs. 500 (508 reputation)Mr or Mrs. 500 (508 reputation)

Group: General Forum Members
Points: 508 Visits: 212
Hi,

Caveat, I've never used or done this before but. . .

there is a Matrix.Columns Property available in SSRS, which will return the number of columns in the report. Based on that, you should be able to determine how many months are being used, and thus calculate an average.

I believe that you will have to write some custom code to get to that property (Report, Report Properties, Code) or write you own class/assembly using the language of your choice.

Otherwise, I would consider calculating it ahead of time in your SQL if possible.

Good luck.
Lrobinson 93181
Lrobinson 93181
Valued Member
Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)

Group: General Forum Members
Points: 65 Visits: 140
Thank you, I will give that a try, and update you if I can get the results I require.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search