Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

SSRS 3.0 average Expand / Collapse
Author
Message
Posted Thursday, September 19, 2013 7:12 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, December 2, 2013 10:56 AM
Points: 24, Visits: 134
Hi all,

I am trying to do an average of a calculated collumn in SSRS (matrix table), the column in question is the result of an expression =sum(Fields!Current_AR.Value) / sum(Fields!Total_AR.Value), now i want to do the average of this collumn but i cant seem to do it..

Anyone got a suggestion?


Best regards,

Daniel
Post #1496377
Posted Thursday, September 19, 2013 8:09 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Thursday, December 11, 2014 2:11 PM
Points: 3,206, Visits: 1,399
Comes down to whether you want the ratio of the current_AR to total_AR at all levels or the ratio of the detail level averaged at each level. The values would be the same at the detail level but change on the summary level. Most business users want the ratio of current_AR to total_AR at all levels.

Example :

Customer [A]
Current_AR, Total_AR
12, 30
10, 50
62, 100

Customer [B]
Current_AR, Total_AR
90, 100

The formula you have used on each detail row is =sum(Fields!Current_AR.Value) / sum(Fields!Total_AR.Value)

So this would give :

A 12 30 40.00%
A 10 50 20.00%
A 62 150 62.00%
B 90 100 90.00%

If you add a group for customer using the same formula for each column would add the group footer rows:

A 84 180 46.67%
B 90 100 90.00%

Grouping to a tablix total would add:

Total 174 280 62.14%

You may not need to use the AVG function at all.

If you were to add the additional column RATIO into the dataset below then you could use the AVG function on these values but get a different returned value within the report.

SELECT *, Current_AR / Total_AR as Ratio
FROM dbo.SourceTable

RATIO
A 12 30 40.00%
A 10 50 20.00%
A 62 150 62.00%
B 90 100 90.00%

If you add a group for customer using the same formula for each column would add the group footer rows:

A 84 180 40.67% (avg of 40.00,20.00 and 62.00)
B 90 100 90.00%

Grouping to a tablix total would add:

Total 174 280 53.00% (avg of 40.00, 20.00, 62.00 and 90.00)

Fitz
Post #1496417
Posted Friday, September 20, 2013 12:55 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, June 2, 2014 7:13 AM
Points: 45, Visits: 151
add your aggregate fields as a calculated filedS then use average function.

Post #1496724
Posted Friday, September 20, 2013 4:21 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, December 2, 2013 10:56 AM
Points: 24, Visits: 134
Hi Mark,

Not sure if i understood what you mean, let me give another go at explaining, i need to sum all the values and divide the result by the number of rows, how would it be the best way to get there?

Below some of the expressions used on the column:

Line by line expression (to obtain USD current amount for each Area and SubArea in your example customer):

=Sum(Fields!Total_AR.Value)*
IIf
(
Fields!SubArea.Value = "Unassigned",
Lookup
(
"% Current" & Fields!Area.Value & Parameters!Period.Label,
Fields!Metric.Value & Fields!Area.Value & Fields!Fiscal_Month.Value,
Fields!Target.Value,
"Target"
),
Lookup
(
"% Current" & Fields!SubArea.Value & Parameters!Period.Label,
Fields!Metric.Value & Fields!Area.Value & Fields!Fiscal_Month.Value,
Fields!Target.Value,
"Target"
)
)
Post #1496787
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse