<?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://lukehayler.com/tag/reporting-services/feed/" rel="self" type="application/rss+xml" />
	<link>http://lukehayler.com</link>
	<description>A blog about Business Intelligence and other personal interests</description>
	<lastBuildDate>Tue, 13 Dec 2011 11:42:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Sorting on Multiple Columns in SSRS</title>
		<link>http://lukehayler.com/2011/04/sorting-on-multiple-columns-in-ssrs/</link>
		<comments>http://lukehayler.com/2011/04/sorting-on-multiple-columns-in-ssrs/#comments</comments>
		<pubDate>Thu, 28 Apr 2011 00:36:30 +0000</pubDate>
		<dc:creator>Luke Hayler</dc:creator>
				<category><![CDATA[Reporting Services]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>
		<category><![CDATA[Column Sorting]]></category>
		<category><![CDATA[Matrix]]></category>
		<category><![CDATA[Table]]></category>

		<guid isPermaLink="false">http://lukehayler.com/2011/04/sorting-on-multiple-columns-in-ssrs/</guid>
		<description><![CDATA[There have been several cases lately where people have asked the question “Can I sort on multiple columns in my Table/Matrix report?” More often than not the answer given is an emphatic “No”. The fact is that you CAN sort &#8230; <a href="http://lukehayler.com/2011/04/sorting-on-multiple-columns-in-ssrs/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>There have been several cases lately where people have asked the question “Can I sort on multiple columns in my Table/Matrix report?” More often than not the answer given is an emphatic “No”. The fact is that you CAN sort on multiple columns by simply incorporating use of&#160; the <strong>Shift </strong>key.</p>
<p>Assuming you have already set up interactive sorting on the columns you want to be able to sort by; run/preview your report. As you are already aware, the columns which can be sorted on have a two tiny arrows right-aligned in the column header. To sort on any one column just click on the arrows. Click on the arrow again to sort in the other direction.</p>
<p><a href="http://lukehayler.com/wp-content/uploads/2011/04/MultipleColumnSorting.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="MultipleColumnSorting" border="0" alt="MultipleColumnSorting" src="http://lukehayler.com/wp-content/uploads/2011/04/MultipleColumnSorting_thumb.png" width="556" height="499" /></a></p>
<p>To sort on multiple columns, hold down the <strong>Shift key</strong> whilst clicking the arrows icons of the columns that you want to sort on. Start with the column you want to sort on first and then move to the next sort order, etc, etc. Click on any column arrow icon twice to change the direction (continue to hold down the Shift key until you have sorted on all the columns you wish to sort by).</p>
<p align="center"><font color="#a5a5a5" size="1"><em>Dataset sorted by Year (asc), Quarter (asc), Total (desc)</em></font><a href="http://lukehayler.com/wp-content/uploads/2011/04/MultipleColumnSorting_2.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="MultipleColumnSorting_2" border="0" alt="MultipleColumnSorting_2" src="http://lukehayler.com/wp-content/uploads/2011/04/MultipleColumnSorting_2_thumb.png" width="556" height="499" /></a></p>
<p>And there you have it. Multiple Column sorting in SSRS!</p>
]]></content:encoded>
			<wfw:commentRss>http://lukehayler.com/2011/04/sorting-on-multiple-columns-in-ssrs/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>T-SQL Tuesday #016 – Aggregations</title>
		<link>http://lukehayler.com/2011/03/t-sql-tuesday-016-aggregations/</link>
		<comments>http://lukehayler.com/2011/03/t-sql-tuesday-016-aggregations/#comments</comments>
		<pubDate>Tue, 08 Mar 2011 02:30:00 +0000</pubDate>
		<dc:creator>Luke Hayler</dc:creator>
				<category><![CDATA[Luke Hayler]]></category>
		<category><![CDATA[Reporting Services]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>
		<category><![CDATA[Matrix]]></category>
		<category><![CDATA[sql server 2005]]></category>
		<category><![CDATA[SSRS]]></category>
		<category><![CDATA[tsql2sday]]></category>

		<guid isPermaLink="false">http://www.lukehayler.com/2011/03/t-sql-tuesday-016-aggregations/</guid>
		<description><![CDATA[It’s T-SQL Tuesday time again! If you are not sure what T-SQL Tuesday is about then go and read this article written by Adam Machanic (Twitter &#124; Blog). This month’s T-SQL Tuesday is brought to us by Jess Borland (Blog &#8230; <a href="http://lukehayler.com/2011/03/t-sql-tuesday-016-aggregations/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a come-one-come-all-to?="come-one-come-all-to?" DBProgramming="DBProgramming" DataMgmt="DataMgmt" index.php="index.php" blogs.lessthandot.com="blogs.lessthandot.com" href:?http:="href:?http:"><img style="display: inline; float: left" align="left" src="http://blogs.lessthandot.com/media/blogs/DataMgmt/olap_1.gif" /></a> It’s T-SQL Tuesday time again! If you are not sure what T-SQL Tuesday is about then go and <a href="http://sqlblog.com/blogs/adam_machanic/archive/2009/11/30/invitation-to-participate-in-t-sql-tuesday-001-date-time-tricks.aspx" target="_blank">read this article</a> written by Adam Machanic (<a href="http://twitter.com/#%21/AdamMachanic">Twitter </a>| <a href="http://sqlblog.com/blogs/adam_machanic/">Blog</a>). <a href="http://blogs.lessthandot.com/index.php/DataMgmt/DBProgramming/come-one-come-all-to" target="_blank">This month’s T-SQL Tuesday</a> is brought to us by Jess Borland (<a href="http://blogs.lessthandot.com/index.php?disp=authdir&amp;author=420" target="_blank">Blog</a> | <a href="http://www.twitter.com/grrl_geek" target="_blank">@grrl_geek</a>) and the topic is “Aggregation”. So let’s get started.</p>
<p>Matrix objects in SQL Server Reporting Services lend themselves to aggregation. With row and column groups prevalent in so many report requirements, it is inevitable that there will be subtotals at many different levels. Understanding <strong>Scope</strong> will enable you to refine your matrix object by applying different aggregate functions (or formatting options) to specific cells, or set of cells. </p>
<p>This is a post that I have been meaning to write for quite some time. In fact, ever since I did my original post on <a href="http://www.lukehayler.com/2009/07/the-inscope-function-and-the-key-to-formatting-subtotals-in-ssrs-matrix-objects/" target="_blank">The InScope() Function and the key to formatting Matrix objects</a>, I’ve been threatening to do it. This stems from all the comments and questions (via email) that I get relating to that post. Most of which are due to a lack of understanding of “scope”. So, while this may seem a trivial subject to a few of you, there are a lot of folks who just aren’t quite there yet. Also, this post is aimed at <strong>Reporting Services 2005</strong> – I know that we are well into 2008 R2 by now, but I am aware that there are still many many companies out there who have yet to make that leap. Thankfully Reporting Services 2008 R2 deals with matrix subtotals in a much more user-friendly way. </p>
<p>&#160;</p>
<p>Scope can be defined as (<a href="http://www.thefreedictionary.com/scope" target="_blank">care of the Free Dictionary</a>):</p>
<blockquote><p>The area covered by a given activity or subject</p>
</blockquote>
<p>For example: Applying this to a Matrix object, we can say that all the cells <strong>covered</strong> by a particular Column (or Column Group) header are <strong>in-scope</strong> of that particular Column (or Column Group) header.</p>
<p>I’ll use the matrix layout below as a template to attempt to explain this in a little more detail. This matrix has the following details:</p>
<ul>
<li>A row detail [group] named “Countries” </li>
<li>A row group named “Regions” </li>
<li>A subtotal on the row details (“Region [1/2] Subtotal”) </li>
<li>A [Sub]total on the row group (“Grand Total (Region)”) </li>
<li>A column detail [group] named “Quarters” </li>
<li>A column group named “Years” </li>
<li>A subtotal on column details (2009/2010 Subtotal) </li>
<li>A [Sub]total on the column group (“Grand Total (Years)”) </li>
</ul>
<p><a href="http://lukehayler.com/wp-content/uploads/2011/03/image.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lukehayler.com/wp-content/uploads/2011/03/image_thumb.png" width="644" height="195" /></a></p>
<p><font color="#666666" size="1">Fig 1. Matrix object</font></p>
<p>For each of the figures below I have included a description of the scope that is being highlighted as well as an expression that can be used to generate the background colour for the cells that fall in-scope of the named group.</p>
<p>&#160;</p>
<p>Fig 2. below shows the scope of the Row Details Group (“Countries”). All cells that fall within these rows (including the subtotals &amp; grand totals) are within the scope of the Row Details Group.</p>
<p><a href="http://lukehayler.com/wp-content/uploads/2011/03/image1.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lukehayler.com/wp-content/uploads/2011/03/image_thumb1.png" width="644" height="195" /></a></p>
<p><font color="#666666" size="1">Fig 2. Matrix object &#8211; Row Details (“Countries”) Scope</font></p>
<blockquote><p><em>=IIF(InScope(“Countries”), “Green”, “White”)</em></p>
</blockquote>
<p>&#160;</p>
<p>Fig 3. below shows the scope of the Column Details Group (“Quarters”). All cells that fall within these columns (including the subtotals &amp; grand totals) are within the scope of the Column Details Group.</p>
<p><a href="http://lukehayler.com/wp-content/uploads/2011/03/image2.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lukehayler.com/wp-content/uploads/2011/03/image_thumb2.png" width="644" height="193" /></a></p>
<p><font color="#666666" size="1">Fig 3. Matrix object &#8211; Column Details (“Quarters”) Scope</font></p>
<blockquote><p><em>=IIF(InScope(“Quarters”), “Green”, “White”)</em></p>
</blockquote>
<p>&#160;</p>
<p>Fig 4. below shows all cells that fall within the scope of both the Row &amp; Column Detail Groups <strong>only</strong>.</p>
<p><a href="http://lukehayler.com/wp-content/uploads/2011/03/image3.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lukehayler.com/wp-content/uploads/2011/03/image_thumb3.png" width="644" height="193" /></a></p>
<p><font color="#666666" size="1">Fig 4. Matrix object &#8211; Cells “in-scope” of both Row Details (“Countries”) &amp; Column Details (“Quarters”) </font></p>
<blockquote><p><em>=IIF(InScope(“Countries”), IIF(InScope(“Quarters”), “Green”, “White”), “White”)</em></p>
</blockquote>
<p>&#160;</p>
<p>Fig 5. below shows the scope of the Row Group (“Regions”). All cells falling within these rows are within the scope of the Row Group (“Regions”). Notice how this <em>includes</em>&#160; the Region 1/2 Subtotals – these fall outside of the scope of the Row Detail Group (“Countries”), see fig 2. </p>
<p><a href="http://lukehayler.com/wp-content/uploads/2011/03/image4.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lukehayler.com/wp-content/uploads/2011/03/image_thumb4.png" width="644" height="193" /></a></p>
<p><font color="#666666" size="1">Fig 5. Matrix object – Row Group (“Regions”) Scope</font></p>
<blockquote><p><em>=IIF(InScope(“Regions”), “Green”, “White”)</em></p>
</blockquote>
<p>&#160;</p>
<p>Fig 6. below shows the scope of the Column Group (“Years”). All cells falling within these columns are within the scope of the Column Group<br />
(“Years”). Notice how this <em>includes</em>&#160; the 2009/2010 Subtotals – these fall outside of the scope of the Column Detail Group (“Quarters”), see fig 3. </p>
<p><a href="http://lukehayler.com/wp-content/uploads/2011/03/image5.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lukehayler.com/wp-content/uploads/2011/03/image_thumb5.png" width="644" height="192" /></a></p>
<p><font color="#666666" size="1">Fig 6. Matrix object – Column Group (“Years”) Scope</font></p>
<blockquote><p><em>=IIF(InScope(“Years”), “Green”, “White”)</em></p>
</blockquote>
<p>&#160;</p>
<p>Fig 7. below shows all the cells that fall outside of the scope of the Row Detail Group (“Countries”), but within the scope of the Row Group (“Regions”)</p>
<p><a href="http://lukehayler.com/wp-content/uploads/2011/03/image6.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lukehayler.com/wp-content/uploads/2011/03/image_thumb6.png" width="644" height="192" /></a></p>
<p><font color="#666666" size="1">Fig 7. Matrix object – Cells “out-of-scope” of Row Details (“Countries”), but “in-scope” of Row Group (“Regions”)</font></p>
<blockquote><p><em>=IIF(InScope(“Regions”), I</em><em>IF(InScope(“Countries”), “White”, “Green”)</em><em>, “White”)</em></p>
</blockquote>
<p>&#160;</p>
<p>Fig 8. below shows all the cells that fall outside of the scope of the Column Details Group (“Quarters”), but within the scope of the Column Group (“Years”)</p>
<p><a href="http://lukehayler.com/wp-content/uploads/2011/03/image7.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lukehayler.com/wp-content/uploads/2011/03/image_thumb7.png" width="644" height="192" /></a></p>
<p><font color="#666666" size="1">Fig 8. Matrix object – Cells “out-of-scope” of Column Details (“Quarters”), but “in-scope” of Column Group (“Years”)</font></p>
<blockquote><p><em>=IIF(InScope(“Years”), I</em><em>IF(InScope(“Quarters”), “White”, “Green”)</em><em>, “White”)</em></p>
</blockquote>
<p>&#160;</p>
<p>Fig 9. below shows all cells that fall outside of the scope of both the Row Details Group (“Countries”) and the Row Group (“Regions”)</p>
<p><a href="http://lukehayler.com/wp-content/uploads/2011/03/image8.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lukehayler.com/wp-content/uploads/2011/03/image_thumb8.png" width="644" height="192" /></a></p>
<p><font color="#666666" size="1">Fig 9. Matrix object – Cells “out-of-scope” of Row Details (“Countries”) AND “out-of-scope” of Row Group (“Regions”)</font></p>
<blockquote><p><em>=IIF(InScope(“Regions”), </em><em>“White”, “Green”)</em></p>
</blockquote>
<p>&#160;</p>
<p>Fig 10. below shows all cells that fall outside of the scope of both the Column Details Group (“Quarters”) and the Column Group (“Years”)</p>
<p><a href="http://lukehayler.com/wp-content/uploads/2011/03/image9.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lukehayler.com/wp-content/uploads/2011/03/image_thumb9.png" width="644" height="192" /></a></p>
<p><font color="#666666" size="1">Fig 10. Matrix object – Cells “out-of-scope” of Column Details (“Quarters”) AND “out-of-scope” of Column Group (“Years”)</font></p>
<blockquote><p><em>=IIF(InScope(“Years”), </em><em>“White”, “Green”)</em></p>
</blockquote>
<p>&#160;</p>
<p>Fig 11. below shows all the cells that fall outside of the scope of both the Row Details Group (“Countries”) and the Column Details Group (“Quarters”), but inside the scope of both the Row Group (“Regions”) and the Column Group (“Years”). </p>
<p><a href="http://lukehayler.com/wp-content/uploads/2011/03/image10.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lukehayler.com/wp-content/uploads/2011/03/image_thumb10.png" width="644" height="192" /></a></p>
<p><font color="#666666" size="1">Fig 11. Matrix object – Cells “out-of-scope” of Row Details (“Countries”) AND Column Details(“Quarters”), but “in-scope” of Row Group (“Regions”) AND Column Group (“Years”)</font></p>
<blockquote><p><em>=IIF(InScope(“Regions”), I</em><em>IF(InScope(“Countries”), “White”, IIF(InScope(“Years”), IIF(InScope(“Quarters”), “White”, “Green”))</em><em>, “White”)</em></p>
</blockquote>
<p>&#160;</p>
<p>Fig 12. below shows all the cells that fall outside of the scope of the Row Details Group (“Countries”) and the Column Details Group (“Quarters”) and the Column Group (“Years”), but inside of the scope of the Row Group (“Regions”). </p>
<p><a href="http://lukehayler.com/wp-content/uploads/2011/03/image11.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lukehayler.com/wp-content/uploads/2011/03/image_thumb11.png" width="644" height="192" /></a></p>
<p><font color="#666666" size="1">Fig 12. Matrix object – Cells “in-scope” of Row Group (“Regions”), but “out-of-scope” of Row Details (“Countries”) AND Column Details (“Quarters”) AND Column Group (“Years&#8217;”)</font></p>
<blockquote><p><em>=IIF(InScope(“Regions”), I</em><em>IF(InScope(“Countries”), “White”, IIF(InScope(“Years”), “White”, “Green”))</em><em>, “White”)</em></p>
</blockquote>
<p>&#160;</p>
<p>Fig 13. below shows all the cells that fall outside of the scope of the Row Details Group (“Countries”) and the Row Group (“Regions”) and the Column Details Group (“Quarters”), but inside of the scope of the Column Group (“Years”).</p>
<p><a href="http://lukehayler.com/wp-content/uploads/2011/03/image12.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lukehayler.com/wp-content/uploads/2011/03/image_thumb12.png" width="644" height="192" /></a></p>
<p><font color="#666666" size="1">Fig 13. Matrix object – Cells “in-scope” of Column Group (“Years”), but “out-of-scope” of Column Details (“Quarters”) AND Row Details (“Countries”) AND Row Group (“Regions”)</font></p>
<blockquote><p><em>=IIF(InScope(“Years”), I</em><em>IF(InScope(“Quarters”), “White”, IIF(InScope(“Regions”), “White”, “Green”))</em><em>, “White”)</em></p>
</blockquote>
<p>&#160;</p>
<p>Fig 14. below shows the cell (there can be only one) that falls outside of the scope of any named group in the matrix object</p>
<p><a hr<br />
ef="http://lukehayler.com/wp-content/uploads/2011/03/image13.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lukehayler.com/wp-content/uploads/2011/03/image_thumb13.png" width="644" height="192" /></a></p>
<p><font color="#666666" size="1">Fig 14. Matrix object – Cells “out-of-scope” of all named Row/Column Groups</font></p>
<blockquote><p><em>=IIF(InScope(“Regions”), </em><em>“White”, IIF(InScope(“Years”), “White”, “Green”))</em></p>
</blockquote>
<p>&#160;</p>
<p>Using the knowledge &amp; understanding of the above combinations with SSRS expressions (to define values/formats) will enable you to refine your matrix-based reports and give the end user the required information. </p>
<p>Not sure how to get subtotals in your matrix objects? See my post on <a href="http://www.lukehayler.com/2010/03/creating-subtotals-in-a-matrix-in-ssrs-20052008/" target="_blank">Creating Subtotals in SSRS 2005</a></p>
]]></content:encoded>
			<wfw:commentRss>http://lukehayler.com/2011/03/t-sql-tuesday-016-aggregations/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The InScope() Function and the key to formatting subtotals in SSRS Matrix Objects</title>
		<link>http://lukehayler.com/2009/07/the-inscope-function-and-the-key-to-formatting-subtotals-in-ssrs-matrix-objects/</link>
		<comments>http://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[Luke Hayler]]></category>
		<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. To find out more about Scope please see my post on Understanding Scope Example &#8211; So for the simple matrix report in &#8230; <a href="http://lukehayler.com/2009/07/the-inscope-function-and-the-key-to-formatting-subtotals-in-ssrs-matrix-objects/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></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.<em> To find out more about Scope please <a title="see my post on Understanding Scope" href="http://lukehayler.com/2011/03/t-sql-tuesday-016-aggregations/" target="_blank">see my post on Understanding Scope</a></em></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://lukehayler.com/wp-content/uploads/2010/01/InScopeFunctionExample.jpg"><img style="display: inline; border: 0px;" title="InScopeFunctionExample" src="http://lukehayler.com/wp-content/uploads/2010/01/InScopeFunctionExample_thumb.jpg" border="0" alt="InScopeFunctionExample" 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://lukehayler.com/2009/07/the-inscope-function-and-the-key-to-formatting-subtotals-in-ssrs-matrix-objects/feed/</wfw:commentRss>
		<slash:comments>39</slash:comments>
		</item>
	</channel>
</rss>

