Welcome to DevAuthority.Com Sign in | Join | Help

Reporting Service - Using InScope to do custom subtotals

Imagine you're doing a report of Employee sales figures.  You put together a quick Matrix report in Reporting Services, throwing Employee on the left and Fiscal Quarter across the top, with Sale amount in the data area.  Fabulous, you've just created a useful report in no time.  But now your boss says, "I want the same sort of report showing sales by employee and quater, but for the subtotals on the bottom and the right I want to see how many employees missed their quota each quarter and how many times a particular employee has missed their quota.  Now what do you do?  Reporting Services handy automatic subtotaling isn't going to work.

I discovered this week that the InScope function comes to the rescue!  You see the subtotals at the bottom of the matrix aren't in the scope of your row group(s) and the subtotals on the right edge of the matrix aren't in the scope of your column group(s) so you can use an expression like this in your datacell to get sales amount summed in the data cells and missed quotas summed in the subtotals:

=IIF(InScope('employee') And InScope('quarter'), SUM(Fields!sales_amount.Value), SUM(IIF(SUM(Fields!sales_amount.Value) < Fields!sales_quota.Value, 1, 0)))

Assuming you have 2 groups named 'employee' and 'quarter', this expression says if I'm in the scope of 'employee' and in the scope of 'quarter' (aka I'm in a data cell) then spit out the sum of sales_amount for my groups.  If I'm not (aka I'm in a subtotal) then instead sum up the # of cells where the quota wasn't met.

I hope you've enjoyed my first blog post, it should at least be more useful than "Hello World"!

Published Wednesday, July 06, 2005 9:14 PM by cslatt
Filed Under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: Reporting Service - Using InScope to do custom subtotals

Where I have to use this InScope function. You said to use inside the datacell. Which datacell?

Is that the subtotal datacell's value property expression? I know changing that expression will change only the subtotal text.

Can you please specifically tell where I have to use the InScope function?

I have a Matrix which has values, totals and percentage all coming from database. Again I have a subtotal(RS) against those totals . I dont want percentage to be summed accross. Is there a way to accomplish that using InScope.

Thanks in advance

Promod.
Wednesday, July 13, 2005 4:08 PM by Promod

# re: Reporting Service - Using InScope to do custom subtotals

It goes in the main datacell, where you would normally just have "SUM(Fields!sales_amount.Value)"

Sorry it took me so long to approve your comment, I didn't know where to go in my admin area to see the comments that had been posted. (I'm new!)
Monday, August 22, 2005 3:09 PM by cslatt

# re: Reporting Service - Using InScope to do custom subtotals

You are the man - this is the soloution I have spent days trying to find! I am always looking for ways to manipulate the awefully un-customizable subtotal fields in a matrix - this will come in very handy, thank you!
Thursday, January 05, 2006 12:14 PM by Erik

# re: Reporting Service - Using InScope to do custom subtotals

hai,
i m trying to use the same way u have specified.
=iif(InScope("Billing_type") And InScope("RESOURCE_TYPE"), "150","250")
but still i m getting 250 in both the cells and subtotals.
any help ll be greatly appreciated.
Tuesday, February 14, 2006 10:21 AM by durga

# re: Reporting Service - Using InScope to do custom subtotals

It works great. Now all of my reports have an InScope in it. Most of the reports are customized. Your code snippet made a difference to the reports that I created.
Tuesday, February 28, 2006 2:35 PM by Promod

What do you think?

(required) 
required 
(required)