Question

I have several datasets. One Consisting of a list of users and others that produce a numerator and denominator for various measures for that user

datasets:

users - to query a list of users for the parameter
measure1 - returns a numerator & denominator "where user_id in (@user)"
measure2 - returns a numerator & denominator "where user_id in (@user)"
measure3 - ...etc
measure4 - ...etc
measure5 - ...etc

parameter (used in all of the measures) @user queries the user dataset

desired output:

Suzy

measure # | Suzy %    | all users %
measure 1 |   85 %    |    50 %
measure 2 |   35 %    |    75 %
measure 3...etc
measure 4...etc
measure 5...etc

So far I can calculate one user's % for each measure or all users' % for each measure but not both simultaneously.


How I did it: I'm adding my answer here because I'm giving @Ian-Preston credit for getting me thinking.

So, in my situation the biggest challenge was the constraint of how the information was to be presented. with all of the query logic working it was just a matter of presentation that I struggled with. The report itself contained several datasets which each get passed the same parameter and spit out their own numerator & denominator and then I create % (numerator / denominator).

The challenging part was having to filter out just one user's % but show an all-users % right next to it.

My solution is a lesson in SSRS- do as much of it in SQL so you don't have to do it in SSRS.

for each measure I pulled in an end row that was a total.

instead of

select user_id
,case when ... then 1 else 0 end as num
,case when ... then 1 else 0 end as denom
group by user_id

I did

select isnull(user_id, 'total') as user_id
,case when ... then 1 else 0 end as num
,case when ... then 1 else 0 end as denom
from ...
where ...
group by user_id with rollup

this gave me a totals row at the end of each of the measurement queries

Then I had 2 parameters- @user multi-value hidden parameter, default values from query of users dataset. @filter parameter, available values from query of users dataset

Next, I created 2 tables with my numerator/denominator calculation. One filtered on the @user = total and the other filtered on @filter. I deleted the headers & footers and only kept that one cell since I wanted the formatting described above.

Was it helpful?

Solution

I assume for one user you are using an expression like:

=Fields!Numerator.Value / Fields!Denominator.Value

For all users, you could use an expression like:

=Fields!Numerator.Value / Sum(Fields!Denominator.Value, "measure1")

This will consider all rows in the Dataset when working out the denominator.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top