<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Luke Hayler - SQL Server developer &#187; Reporting Services</title>
	<atom:link href="http://www.lukehayler.com/tag/reporting-services/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lukehayler.com</link>
	<description>A blog about Integration services, Reporting services, and the things that interest me</description>
	<lastBuildDate>Fri, 06 Aug 2010 10:19:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The InScope() Function and the key to formatting subtotals in SSRS Matrix Objects</title>
		<link>http://www.lukehayler.com/2009/07/the-inscope-function-and-the-key-to-formatting-subtotals-in-ssrs-matrix-objects/</link>
		<comments>http://www.lukehayler.com/2009/07/the-inscope-function-and-the-key-to-formatting-subtotals-in-ssrs-matrix-objects/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 21:24:13 +0000</pubDate>
		<dc:creator>Luke Hayler</dc:creator>
				<category><![CDATA[Reporting Services]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>
		<category><![CDATA[SSRS]]></category>

		<guid isPermaLink="false">http://www.lukehayler.com/?p=10</guid>
		<description><![CDATA[What it does
The InScope(&#60;named-scope&#62;) function checks to see if the current item is in the specified scope.
Example &#8211; So for the simple matrix report in Fig 1.:

The Green cells fall out-of-scope of the ColumnGroup, and In-Scope for the RowGroup 
The Grey cells fall out-of-scope of the RowGroup, and In-Scope for the ColumnGroup 
The Light blue [...]]]></description>
			<content:encoded><![CDATA[<p><strong>What it does</strong></p>
<p>The InScope(&lt;named-scope&gt;) function checks to see if the current item is in the specified scope.</p>
<p>Example &#8211; So for the simple matrix report in Fig 1.:</p>
<ul>
<li>The <span style="color: #339966">Green</span> cells fall out-of-scope of the ColumnGroup, and In-Scope for the RowGroup </li>
<li>The <span style="color: #999999">Grey</span> cells fall out-of-scope of the RowGroup, and In-Scope for the ColumnGroup </li>
<li>The <span style="color: #99ccff">Light blue</span> cells fall In-Scope of both the ColumnGroup and the RowGroup. </li>
<li>The <span style="color: #3366ff">Dark blue </span>cell falls out-of-scope of both the ColumnGroup and the RowGroup. </li>
</ul>
<p><strong>What this means</strong></p>
<p>By incorporating an<em> If statement</em> into the party we can decipher which cells should get particular formatting. For example:</p>
<p>Fig 1. A Matrix Object</p>
<p><a href="http://www.lukehayler.com/wp-content/uploads/2010/01/InScopeFunctionExample.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="InScopeFunctionExample" border="0" alt="InScopeFunctionExample" src="http://www.lukehayler.com/wp-content/uploads/2010/01/InScopeFunctionExample_thumb.jpg" width="508" height="240" /></a> </p>
<p><strong>Application</strong></p>
<p>Now let’s apply the above theory. The object is to format the background colour of the cells as shown above:</p>
<ul>
<li>Select the data cell. </li>
<li>Navigate to the background colour property </li>
<li>Select Expression from the drop down list. </li>
<li>Apply the expression: </li>
</ul>
<p style="padding-left: 30px"><em>=IIf(InScope(“ColumnGroup”),</em></p>
<p style="padding-left: 60px"><em>IIf(InScope(“RowGroup”),”LightBlue”, ”Grey”),</em></p>
<p style="padding-left: 90px"><em>IIf(InScope(“RowGroup”),”DarkGreen”, “DarkBlue”)</em></p>
<p style="padding-left: 30px">)</p>
<ul>
<li>Run the report. You should get a colour scheme similar to Fig1. </li>
</ul>
<p>Now this is just a simple example. If you have multiple column and row groups you will have to expand the logic to cater for what is In Scope and what is Out of Scope. The If statements will begin to get a bit messy, but if you use an indented format to initially get the formula out and then reduce it, it becomes easier.</p>
<p><em>You can apply this logic to format any property of the cells. You can also use the logic to change the data shown in the cells. If, for example, you wanted to show an average in the subtotal column instead of a data value, then you would substitute the colour above for the appropriate data expression</em></p>
<p style="padding-left: 30px"><em>=IIf(InScope(“ColumnGroup”),</em></p>
<p style="padding-left: 60px"><em>IIf(InScope(“RowGroup”),Fields!Total.Value, SUM(Fields!Total.Value)),</em></p>
<p style="padding-left: 90px"><em>IIf(InScope(“RowGroup”),SUM(Fields!Total.Value)/Count(Fields!Month.value), Sum(Fields!Total.Value)/Count(Fields!Month.Value)</em></p>
<p style="padding-left: 30px">)</p>
<p>There is another way to format the colour (or other property) of the Subtotal columns/rows. Using this method will apply the same formatting to all cells in the subtotal column/row, including the Grand Total. So, if you want a simple way to blanket format the subtotal of a column or row:</p>
<ul>
<li>Select the Subtotal column/row cell. </li>
<li>Click the little green arrow that appears in the top right corner of the cell (watch out, it’s a tricky little bugger) </li>
<li>Now amend the property that you wish to update. </li>
<li>Done. </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.lukehayler.com/2009/07/the-inscope-function-and-the-key-to-formatting-subtotals-in-ssrs-matrix-objects/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
	</channel>
</rss>
