<?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>Data Inspirations &#187; Reporting Services</title>
	<atom:link href="http://blog.datainspirations.com/category/reporting-services/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.datainspirations.com</link>
	<description>Inspiring Intelligence from Information</description>
	<lastBuildDate>Thu, 02 Feb 2012 01:12:27 +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>Button, Button, Who&#8217;s Got the Button?</title>
		<link>http://blog.datainspirations.com/2011/12/08/button-button-whos-got-the-button/</link>
		<comments>http://blog.datainspirations.com/2011/12/08/button-button-whos-got-the-button/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 13:09:03 +0000</pubDate>
		<dc:creator>Stacia Misner</dc:creator>
				<category><![CDATA[Reporting Services]]></category>

		<guid isPermaLink="false">http://blog.datainspirations.com/?p=575</guid>
		<description><![CDATA[Yes, I&#8217;ve been quiet lately. I have a ton of ideas lining up for blog posts, but I need to get back to a &#8220;normal&#8221; pace. After conference season (PASS and Connections), I have been super busy with various projects &#8211; like co-authoring Introducing SQL Server 2012 with Ross Mistry and teaching classes like BI [...]]]></description>
			<content:encoded><![CDATA[<p>Yes, I&#8217;ve been quiet lately. I have a ton of ideas lining up for blog posts, but I need to get back to a &#8220;normal&#8221; pace. After conference season (PASS and Connections), I have been super busy with various projects &#8211; like co-authoring <a href="http://blogs.msdn.com/b/microsoft_press/archive/2011/10/11/free-ebook-introducing-microsoft-sql-server-code-name-denali-draft-preview.aspx" target="_blank">Introducing SQL Server 2012</a> with Ross Mistry and teaching classes like <a href="http://www.sqlskills.com/T_ImmersionBI.asp" target="_blank">BI Immersion</a> this week. One might say I&#8217;m having too much fun! Is that possible?</p>
<h3>Background</h3>
<p>Today&#8217;s post was inspired by a problem I encountered on the first day of the BI Immersion class. To make things easier for folks to have a working environment in which to try out the topics we discuss during the BI Immersion class, I recommend they get a <a href="http://tinyurl.com/858o27a" target="_blank">freely available VHD</a> with the entire Microsoft BI stack installed and configured. It&#8217;s evaluation software so it only works for a limited time, but it should be enough time for learning until you get your own permanent environment set up. Also, it&#8217;s not quite the entire BI stack, but we fix that during class by adding PowerPivot for SharePoint and adding another Reporting Services instance in SharePoint integrated mode. (Side note: Adding PowerPivot for SharePoint to an existing farm can be challenging &#8211; may need to <a href="http://www.cjvandyk.com/blog/Articles/How%20do%20I%20-%20Install%20PowerPivot%20into%20an%20EXISTING%20SharePoint%202010%20farm.aspx" target="_blank">do some fiddling</a> to get it working.)</p>
<h3>The Problem</h3>
<p>As I was demonstrating Reporting Services (native mode) using the aforementioned VHD, I noticed that the Data Feed button was missing from the HTML Viewer toolbar. Yet, it was there in the toolbar when using Reporting Services in SharePoint integrated mode. You use this button to export data to PowerPivot for Excel &#8211; or any application that can consume an ATOM data feed. Where did the button go?</p>
<h3>The Solution</h3>
<p>My guess is that this VHD was not created from scratch using SQL Server 2008 R2, but rather migrated from an earlier version and somehow the RSReportServer.config file didn&#8217;t update properly. When I looked at the file for clues about the data feed button, I noticed that a rendering extension was missing. I added it back in as shown below (see the highlighted text), then opened up Report Manager to look at a report. Hooray &#8211; the button is back!</p>
<p>(Sorry about the lack of wrapping &#8211; I&#8217;ll fix it later. Have to get to class!)</p>
<pre>&lt;Render&gt;
&lt;Extension Name="XML" Type="Microsoft.ReportingServices.Rendering.DataRenderer.XmlDataReport,Microsoft.ReportingServices.DataRendering"/&gt;
&lt;Extension Name="NULL" Type="Microsoft.ReportingServices.Rendering.NullRenderer.NullReport,Microsoft.ReportingServices.NullRendering" Visible="False"/&gt;
&lt;Extension Name="CSV" Type="Microsoft.ReportingServices.Rendering.DataRenderer.CsvReport,Microsoft.ReportingServices.DataRendering"/&gt;
&lt;Extension Name="PDF" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.PDFRenderer,Microsoft.ReportingServices.ImageRendering"/&gt;
&lt;Extension Name="RGDI" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.RGDIRenderer,Microsoft.ReportingServices.ImageRendering" Visible="False"/&gt;
&lt;Extension Name="HTML4.0" Type="Microsoft.ReportingServices.Rendering.HtmlRenderer.Html40RenderingExtension,Microsoft.ReportingServices.HtmlRendering" Visible="False"/&gt;
&lt;Extension Name="MHTML" Type="Microsoft.ReportingServices.Rendering.HtmlRenderer.MHtmlRenderingExtension,Microsoft.ReportingServices.HtmlRendering"/&gt;
&lt;Extension Name="EXCEL" Type="Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRenderer,Microsoft.ReportingServices.ExcelRendering"/&gt;
&lt;Extension Name="RPL" Type="Microsoft.ReportingServices.Rendering.RPLRendering.RPLRenderer,Microsoft.ReportingServices.RPLRendering" Visible="False" LogAllExecutionRequests="False"/&gt;
&lt;Extension Name="IMAGE" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.ImageRenderer,Microsoft.ReportingServices.ImageRendering"/&gt;
&lt;Extension Name="WORD" Type="Microsoft.ReportingServices.Rendering.WordRenderer.WordDocumentRenderer,Microsoft.ReportingServices.WordRendering"/&gt;
<strong>&lt;Extension Name="ATOM" Type="Microsoft.ReportingServices.Rendering.DataRenderer.AtomDataReport,Microsoft.ReportingServices.DataRendering" Visible="false"/&gt;</strong>
&lt;/Render&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.datainspirations.com/2011/12/08/button-button-whos-got-the-button/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Data Visualizations in SSRS 2008 R2</title>
		<link>http://blog.datainspirations.com/2011/05/13/data-visualizations-in-ssrs-2008-r2/</link>
		<comments>http://blog.datainspirations.com/2011/05/13/data-visualizations-in-ssrs-2008-r2/#comments</comments>
		<pubDate>Fri, 13 May 2011 14:06:35 +0000</pubDate>
		<dc:creator>Stacia Misner</dc:creator>
				<category><![CDATA[Reporting Services]]></category>
		<category><![CDATA[PASS]]></category>
		<category><![CDATA[SQLRally]]></category>
		<category><![CDATA[SSRS]]></category>

		<guid isPermaLink="false">http://blog.datainspirations.com/?p=476</guid>
		<description><![CDATA[Yesterday, I delivered a presentation at SQLRally on the new data visualization features in the latest version of Reporting Services. We did some experimentation with Indicators to validate the rules for Start and End, which sacrificed the later portion of my presentation on visual design best practices. On the one hand, that meant the session [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday, I delivered a presentation at SQLRally on the new data visualization features in the latest version of Reporting Services. We did some experimentation with Indicators to validate the rules for Start and End, which sacrificed the later portion of my presentation on visual design best practices. On the one hand, that meant the session was entirely focused on the new data visualization features which was my intent all along, but if you were more interested in the best practices, you didn&#8217;t get to see that part, so please accept my apologies for the sacrifice. However, keep an eye on this blog for an upcoming series to cover these topics, which will be a much more easily referenced resource than anything I could have said in the session.</p>
<p>Downloads available:</p>
<ul>
<li><a href="http://datainspirations.com/uploads/DataViz.pdf" target="_blank">Presentation slides</a></li>
<li><a href="http://datainspirations.com/uploads/SQLRally.zip" target="_blank">Demonstration project</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.datainspirations.com/2011/05/13/data-visualizations-in-ssrs-2008-r2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multi-State Maps in Reporting Services</title>
		<link>http://blog.datainspirations.com/2011/03/24/multi-state-maps-in-reporting-services/</link>
		<comments>http://blog.datainspirations.com/2011/03/24/multi-state-maps-in-reporting-services/#comments</comments>
		<pubDate>Thu, 24 Mar 2011 13:22:15 +0000</pubDate>
		<dc:creator>Stacia Misner</dc:creator>
				<category><![CDATA[Reporting Services]]></category>
		<category><![CDATA[spatial data]]></category>
		<category><![CDATA[SSRS]]></category>

		<guid isPermaLink="false">http://blog.datainspirations.com/?p=389</guid>
		<description><![CDATA[In SQL Server 2008 R2 Reporting Services, you can now create maps for reports using the built-in map gallery of the United States or individual states, ESRI shapefiles, or a spatial query. In a previous post, I explained how to obtain an ESRI shapefile for another country and convert it into spatial data so that [...]]]></description>
			<content:encoded><![CDATA[<p>In SQL Server 2008 R2 Reporting Services, you can now create maps for reports using the built-in map gallery of the United States or individual states, ESRI shapefiles, or a spatial query. In a <a title="SQL Server 2008 R2 Reporting Services – The World is But a Stage (T-SQL Tuesday #006)" href="http://blog.datainspirations.com/2010/05/11/sql-server-2008-r2-reporting-services-the-word-is-but-a-stage-t-sql-tuesday-006/" target="_blank">previous post</a>, I explained how to obtain an ESRI shapefile for another country and convert it into spatial data so that you can have other maps available in the map gallery. In this post, I&#8217;ll show you how to create one map from multiple ESRI shapefiles. Whether you add it to the map gallery or not is up to you!</p>
<p><strong>Obtaining State Shapefiles</strong></p>
<p>To start, the process is similar to the one I described in my previous post on working with spatial data. This time my goal is to create a map of two states &#8211; Nevada and California. The best place to download free shapefiles for US states is the <a href="http://www.census.gov/geo/www/tiger/tgrshp2010/tgrshp2010.html" target="_blank">U.S. Census Bureau</a> where I used the link to download by state. I found the Nevada directory and then used the topmost directory 32 where there many files to download. I chose tl_2010_32_state00.zip. Similarly in the California directory, I used the topmost directory to find and download tl_2010_06_state00.zip.  Then I extracted each zip file to its own directory on my computer. They each contain a variety of files, including SHP and DBF files that I could use for a map using the ESRI shapefile data source option if I want to create a separate map for each state. But I want to combine these maps, so my mission is not yet complete.</p>
<p><strong>Converting Shapefiles to SQL Spatial Data</strong></p>
<p>My next step is to use a tool called <a href="http://www.sharpgis.net/page/SQL-Server-2008-Spatial-Tools.aspx" target="_blank">Shape2SQL</a> to extract the spatial data from the shapefile into a SQL Server table. Pinal Dave (<a href="http://blog.sqlauthority.com/" target="_blank">blog</a>|<a href="http://twitter.com/PinalDave" target="_blank">twitter</a>) has a <a title="SQL SERVER – World Shapefile Download and Upload to Database – Spatial Database" href="http://blog.sqlauthority.com/2010/03/30/sql-server-world-shapefile-download-and-upload-to-database-spatial-database/" target="_blank">tutorial </a>explaining how to do that. I had the same experience that I described in my last post &#8211; I had to clear the Create Spatial Index checkbox to get the table to load properly for the first state. When I loaded the second state, I had to clear the Replace Existing Table checkbox. Now I have both states in a table called State, as shown below, with a geom column having the SQL Geometry data type.</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2011/03/StateTable.jpg"><img class="alignnone size-full wp-image-390" title="StateTable" src="http://blog.datainspirations.com/wp-content/uploads/2011/03/StateTable.jpg" alt="" width="623" height="27" /></a></p>
<p><strong>Creating the Multi-State Map</strong></p>
<p>Now that I have my spatial data in a table, I&#8217;m ready to create the map. In Business Intelligence Development Studio, I added the map to my report which launched the Map Wizard and then I used the following steps:</p>
<ol>
<li>On the <strong>Choose a source of spatial data</strong> page of the wizard, select <strong>SQL Server spatial query</strong>, and click <strong>Next</strong>.</li>
<li>On the <strong>Choose a dataset with SQL Server spatial data</strong> page, select <strong>Add a new dataset with SQL Server spatial data</strong>.</li>
<li>On the <strong>Choose a connection to a SQL Server spatial data source</strong> page, select <strong>New</strong>.</li>
<li>In the <strong>Data Source Properties</strong> dialog box, on the <strong>General</strong> page, add a connecton string like this (changing your server name if necessary):<br />
<code>Data Source=(local);Initial Catalog=SpatialData</code></li>
<li>Click <strong>OK</strong> and then click <strong>Next</strong>.</li>
<li>On the <strong>Design a query</strong> page, add a query for the country shape, like this:<br />
<code>SELECT  NAME00, geom FROM State</code></li>
<li>Click <strong>Next</strong>. The map wizard reads the spatial data and renders it for you on the <strong>Choose spatial data and map view options</strong> page, as shown below.</li>
</ol>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2011/03/NevadaCalifornia.jpg"><img class="alignnone size-full wp-image-391" title="NevadaCalifornia" src="http://blog.datainspirations.com/wp-content/uploads/2011/03/NevadaCalifornia.jpg" alt="" width="594" height="338" /></a></p>
<p>Of course, you can use these technique with any shapefiles that you can locate. It&#8217;s not limited to the United States. For example, if you want to create a map of multiple European countries or a combination of states in India, you could use a similar process by downloading shapefiles from either the <a href="http://www.gadm.org/country" target="_blank">Global Administrative Areas spatial database</a> or the <a href="http://www.naturalearthdata.com/downloads/" target="_blank">Natural Earth database</a>.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.datainspirations.com/2011/03/24/multi-state-maps-in-reporting-services/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Case of the Extra Page: Rendering Reporting Services as PDF</title>
		<link>http://blog.datainspirations.com/2011/03/18/the-case-of-the-extra-page/</link>
		<comments>http://blog.datainspirations.com/2011/03/18/the-case-of-the-extra-page/#comments</comments>
		<pubDate>Fri, 18 Mar 2011 18:44:27 +0000</pubDate>
		<dc:creator>Stacia Misner</dc:creator>
				<category><![CDATA[Reporting Services]]></category>
		<category><![CDATA[SSRS]]></category>

		<guid isPermaLink="false">http://blog.datainspirations.com/?p=377</guid>
		<description><![CDATA[I had to troubleshoot a problem with a mysterious extra page appearing in a PDF this week. My first thought was that it was likely to caused by one of the most common problems that people encounter when developing reports that eventually get rendered as PDF is getting blank pages inserted into the PDF document. [...]]]></description>
			<content:encoded><![CDATA[<p>I had to troubleshoot a problem with a mysterious extra page appearing in a PDF this week. My first thought was that it was likely to caused by one of the most common problems that people encounter when developing reports that eventually get rendered as PDF is getting blank pages inserted into the PDF document. The cause of the blank pages is usually related to sizing. You can learn more at <a href="http://msdn.microsoft.com/en-us/library/bb677374.aspx" target="_blank">Understanding Pagination in Reporting Services</a> in Books Online.</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2011/03/PageSize.jpg"><img class="alignnone size-full wp-image-378" title="PageSize" src="http://blog.datainspirations.com/wp-content/uploads/2011/03/PageSize.jpg" alt="" width="571" height="352" /></a></p>
<p>When designing a report, you have to be really careful with the layout of items in the body. As you move items around, the body will expand to accommodate the space you&#8217;re using and you might eventually tighten everything back up again, but the body doesn&#8217;t automatically collapse. One of my favorite things to do in Reporting Services 2005 &#8211; which I dubbed the &#8220;vacu-pack&#8221; method &#8211; was to just erase the size property of the Body and let it auto-calculate the new size, squeezing out all the extra space. Alas, that method no longer works beginning with Reporting Services 2008. Even when you make sure the body size is as small as possible (with no unnecessary extra space along the top, bottom, left, or right side of the body), it&#8217;s important to calculate the body size plus header plus footer plus the margins and ensure that the calculated height and width do not exceed the report&#8217;s height and width (shown as the page in the illustration above). This won&#8217;t matter if users always render reports online, but they&#8217;ll get extra pages in a PDF document if the report&#8217;s height and width are smaller than the calculate space.</p>
<p><strong>Beginning the Investigation</strong></p>
<p>In the situation that I was troubleshooting, I checked the properties:</p>
<table border="1" cellspacing="0" cellpadding="2" width="590">
<tbody>
<tr>
<td width="158" valign="top"><strong>Item</strong></td>
<td width="113" valign="top"><strong>Property</strong></td>
<td width="56" valign="top"><strong>Value</strong></td>
</tr>
<tr>
<td width="158" valign="top">Body</td>
<td width="113" valign="top">Height</td>
<td width="56" valign="top">6.25in</td>
</tr>
<tr>
<td width="158" valign="top"></td>
<td width="113" valign="top">Width</td>
<td width="56" valign="top">10.5in</td>
</tr>
<tr>
<td width="158" valign="top">Page Header</td>
<td width="113" valign="top">Height</td>
<td width="56" valign="top">1in</td>
</tr>
<tr>
<td width="158" valign="top">Page Footer</td>
<td width="113" valign="top">Height</td>
<td width="56" valign="top">0.25in</td>
</tr>
<tr>
<td width="158" valign="top">Report</td>
<td width="113" valign="top">Left Margin</td>
<td width="56" valign="top">0.1in</td>
</tr>
<tr>
<td width="158" valign="top"></td>
<td width="113" valign="top">Right Margin</td>
<td width="56" valign="top">0.1in</td>
</tr>
<tr>
<td width="158" valign="top"></td>
<td width="113" valign="top">Top Margin</td>
<td width="56" valign="top">0.05in</td>
</tr>
<tr>
<td width="158" valign="top"></td>
<td width="113" valign="top">Bottom Margin</td>
<td width="56" valign="top">0.05in</td>
</tr>
<tr>
<td width="158" valign="top"></td>
<td width="113" valign="top">Page Size &#8211; Height</td>
<td width="56" valign="top">8.5in</td>
</tr>
<tr>
<td width="158" valign="top"></td>
<td width="113" valign="top">Page Size &#8211; Width</td>
<td width="56" valign="top">11in</td>
</tr>
</tbody>
</table>
<p>So I calculated the total width using Body Width + Left Margin + Right Margin and came up with a value of 10.7 inches. And then I calculated the total height using Body Height + Page Header Height + Page Footer Height + Top Margin + Bottom Margin and got 7.6 inches. Well, page sizing couldn&#8217;t be the reason for the extra page in my report because 10.7 inches is smaller than the report&#8217;s width of 11 inches and 7.6 inches is smaller than the report&#8217;s height of 8.5 inches. I had to look elsewhere to find the culprit.</p>
<p><strong>Conducting the Third Degree</strong></p>
<p>My next thought was to focus on the rendering size of the items in the report. I&#8217;ve adapted my problem to use the Adventure Works database. At the top of the report are two charts, and then below each chart is a rectangle that contains a table.</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2011/03/DashboardPreview.jpg"><img class="alignnone size-full wp-image-380" style="border: 1px solid black;" title="DashboardPreview" src="http://blog.datainspirations.com/wp-content/uploads/2011/03/DashboardPreview.jpg" alt="" width="530" height="430" /></a></p>
<p>In the real-life scenario, there were some graphics present as a background for the tables which fit within the rectangles that were about 3 inches high so the visual space of the rectangles matched the visual space of the charts &#8211; also about 3 inches high. But there was also a huge amount of white space at the bottom of the page, and as I mentioned at the beginning of this post, a second page which was blank except for the footer that appeared at the bottom. Placing a textbox beneath the rectangles to see if they would appear on the first page resulted the textbox&#8217;s appearance on the second page. For some reason, the rectangles wanted a buffer zone beneath them. What&#8217;s going on?</p>
<p><strong>Taking the Suspect into Custody</strong></p>
<p>My next step was to see what was really going on with the rectangle. The graphic appeared to be correctly sized, but the behavior in the report indicated the rectangle was growing. So I added a border to the rectangle to see what it was doing.</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2011/03/RectanglesPreview.jpg"><img class="alignnone size-full wp-image-381" title="RectanglesPreview" src="http://blog.datainspirations.com/wp-content/uploads/2011/03/RectanglesPreview.jpg" alt="" width="611" height="226" /></a></p>
<p>When I added borders, I could see that the size of each rectangle was growing to accommodate the table it contains. The rectangle on the right is slightly larger than the one on the left because the table on the right contains an extra row. The rectangle is trying to preserve the whitespace that appears in the layout, as shown below.</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2011/03/Whitespace.jpg"><img class="alignnone size-full wp-image-382" title="Whitespace" src="http://blog.datainspirations.com/wp-content/uploads/2011/03/Whitespace.jpg" alt="" width="500" height="292" /></a></p>
<p><strong>Closing the Case</strong></p>
<p>Now that I knew what the problem was, what could I do about it? Because of the graphic in the rectangle (not shown), I couldn&#8217;t eliminate the use of the rectangles and just show the tables. But fortunately, there is a report property that comes to the rescue: ConsumeContainerWhitespace (accessible only in the Properties window). I set the value of this property to True. Problem solved. Now the rectangles remain fixed at the configured size and don&#8217;t grow vertically to preserve the whitespace. Case closed.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.datainspirations.com/2011/03/18/the-case-of-the-extra-page/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Applying Interactive Sorting to Multiple Columns in Reporting Services</title>
		<link>http://blog.datainspirations.com/2011/03/16/applying-interactive-sorting-to-multiple-columns-in-reporting-services/</link>
		<comments>http://blog.datainspirations.com/2011/03/16/applying-interactive-sorting-to-multiple-columns-in-reporting-services/#comments</comments>
		<pubDate>Wed, 16 Mar 2011 17:55:22 +0000</pubDate>
		<dc:creator>Stacia Misner</dc:creator>
				<category><![CDATA[Reporting Services]]></category>
		<category><![CDATA[SSRS]]></category>

		<guid isPermaLink="false">http://blog.datainspirations.com/?p=369</guid>
		<description><![CDATA[A nice feature that appeared first in SQL Server 2005 (not SQL Server 2008 &#8211; I mis-remembered!) is the ability to allow the user to click a column header to sort that column. It defaults to an ascending sort first, but you can click the column again to switch to a descending sort. You can learn [...]]]></description>
			<content:encoded><![CDATA[<p>A nice feature that appeared first in SQL Server 2005 (not SQL Server 2008 &#8211; I mis-remembered!) is the ability to allow the user to click a column header to sort that column. It defaults to an ascending sort first, but you can click the column again to switch to a descending sort. You can learn more about interactive sorts in general at the <a href="http://msdn.microsoft.com/en-us/library/cc627536.aspx" target="_blank">Adding Interactive Sort to a Data Region</a> in Books Online. Not mentioned in the article is how to apply interactive sorting to multiple columns, hence the reason for this post!</p>
<p>Let’s say that I have a simple table like this:</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2011/03/ReportToSort.png"><img class="size-full wp-image-371 alignnone" title="ReportToSort" src="http://blog.datainspirations.com/wp-content/uploads/2011/03/ReportToSort.png" alt="" width="359" height="81" /></a></p>
<p>To enable interactive sorting, I open the Text Box properties for each of the column headers – the ones in the top row. Here’s an example of how I set up basic interactive sorting:</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2011/03/TextBoxProperties.png"><img class="alignnone size-full wp-image-372" title="TextBoxProperties" src="http://blog.datainspirations.com/wp-content/uploads/2011/03/TextBoxProperties.png" alt="" width="577" height="521" /></a></p>
<p>Now when I preview the report, I see icons appear in each text box on the header row to indicate that interactive sorting is enabled. The initial sort order that displays when you preview the report depends on how you design the report. In this case, the report sorts by Sales Territory Group first, and then by Calendar Year.</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2011/03/InteractiveSortReport.png"><img class="alignnone size-full wp-image-373" title="InteractiveSortReport" src="http://blog.datainspirations.com/wp-content/uploads/2011/03/InteractiveSortReport.png" alt="" width="366" height="290" /></a></p>
<p>Interactive sorting overrides the report design. So let’s say that I want to sort first by Calendar Year, and then by Sales Territory Group. To do this, I click the arrow to the right of Calendar Year, and then, while pressing the Shift key, I click the arrow to the right of Sales Territory Group twice (once for ascending order and then a second time for descending order). Now my report looks like this:</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2011/03/MultiSort.png"><img class="alignnone size-full wp-image-374" title="MultiSort" src="http://blog.datainspirations.com/wp-content/uploads/2011/03/MultiSort.png" alt="" width="363" height="288" /></a></p>
<p>This technique only seems to work when you have a minimum of three columns configured with interactive sorting. If I remove the property from one of the columns in the above example, and try to use the interactive sorting on the remaining two columns, I can sort only the first column. The sort on the second column gets ignored. I don’t know if that’s by design or a bug, but I do know that’s what I’m experiencing when I try it out!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.datainspirations.com/2011/03/16/applying-interactive-sorting-to-multiple-columns-in-reporting-services/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Retrieving Aggregate Data from Analysis Services for Reports</title>
		<link>http://blog.datainspirations.com/2011/03/08/retrieving-aggregate-data/</link>
		<comments>http://blog.datainspirations.com/2011/03/08/retrieving-aggregate-data/#comments</comments>
		<pubDate>Tue, 08 Mar 2011 23:40:24 +0000</pubDate>
		<dc:creator>Stacia Misner</dc:creator>
				<category><![CDATA[Reporting Services]]></category>
		<category><![CDATA[SSAS]]></category>
		<category><![CDATA[SSRS]]></category>
		<category><![CDATA[T-SQL Tuesday]]></category>

		<guid isPermaLink="false">http://blog.datainspirations.com/?p=356</guid>
		<description><![CDATA[It’s the second Tuesday of the month, so that means it’s T-SQL Tuesday! This month’s host is Jes Borland (blog &#124; twitter) and the topic is Aggregate Functions. I agree with Doug Lane (blog &#124; twitter), who pointed out in his T-SQL Tuesday post that it’s best if you use the database engine to calculate [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/1dc72ec994ab_7A55/TSQL2sDay150x150.jpg"><img style="background-image: none; margin: 0px 8px 3px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; padding-top: 0px; border-width: 0px;" title="TSQL2sDay150x150" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/1dc72ec994ab_7A55/TSQL2sDay150x150_thumb.jpg" border="0" alt="TSQL2sDay150x150" width="154" height="154" align="left" /></a>It’s the second Tuesday of the month, so that means it’s T-SQL Tuesday! This month’s host is Jes Borland (<a href="http://blogs.lessthandot.com/index.php/All/?author=420" target="_blank">blog</a> | <a href="http://twitter.com/grrl_geek" target="_blank">twitter</a>) and the topic is <a href="http://blogs.lessthandot.com/index.php/DataMgmt/DBProgramming/come-one-come-all-to" target="_blank">Aggregate Functions</a>.</p>
<p>I agree with Doug Lane (<a href="http://www.douglane.net" target="_blank">blog</a> | <a href="http://twitter.com/douglane4" target="_blank">twitter</a>), <a href="http://www.douglane.net/2011/03/t-sql-tuesday-016-aggregations-in-reporting-services/" target="_blank">who pointed out in his T-SQL Tuesday post</a> that it’s best if you use the database engine to calculate aggregates rather than use aggregate functions in Reporting Services. There are some things the database engine can simply do better, and we should use the best tool for the job. But an even better way to work with aggregated data, in my opinion, is to put data into a cube and let Analysis Services do the calculations. Either way, whether you use a relational source like SQL Server or a multidimensional source like Analysis Services, the point is that the back-end engines will always outperform Reporting Services. On the back-end, Analysis Services should outperform SQL Server if the cube and the report query are both designed properly.</p>
<p>That said, there is some trickiness involved when  retrieving and using aggregations in reports. I was having a déjà vu moment as I was writing this blog and sure enough I found that I had touched on the subject several years ago in my blog post, <a href="http://blog.datainspirations.com/2007/04/04/showing-server-aggregations-in-reporting-services/" target="_blank">Showing Server Aggregations in Reporting Services</a>. The post was written in reference to Reporting Services 2005, but the principles still apply. In today’s post, I’ll revisit the same query but add in some pictures this time to help clarify.</p>
<h5>The Problem</h5>
<p>If I create a table using the query from the referenced post, and if I add a total row using the Reporting Services SUM function, I get this result:</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2011/03/Tablix11.png"><img class="alignleft size-full wp-image-359" title="Tablix1" src="http://blog.datainspirations.com/wp-content/uploads/2011/03/Tablix11.png" alt="" width="506" height="162" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>The SUM function would work just fine if I were to use an additive measure, like SalesAmount, but the SUM function doesn’t work at all with non-additive measures like Gross Profit Margin. It adds up the percentage values to produce the total row value but it really needs to compute the sum of sales and the sum of costs separately and then do the math to compute the correct result.</p>
<h5>The Solution</h5>
<p>Instead of using the SUM function, we can use the AGGREGATE function instead. That is we replace this expression:</p>
<p><span style="font-family: 'Courier New';">=Sum(Fields!Gross_Profit_Margin.Value)</span></p>
<p>with this expression:</p>
<p><span style="font-family: 'Courier New';">=Aggregate(Fields!Gross_Profit_Margin.Value)</span></p>
<h5>Where’s the Value?</h5>
<p>When I make the change to the expression and preview the report, I find that I have a new problem – the total row is now missing a value completely!</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2011/03/Tablix1.png"><img title="Tablix1" src="http://blog.datainspirations.com/wp-content/uploads/2011/03/Tablix1.png" alt="" width="498" height="162" /></a></p>
<p>&nbsp;</p>
<p>The reason is that the Aggregate function requires me to use a query in design mode only, not in query mode. (At least that’s the case in Reporting Services 2008 R2. I don’t remember that this was true in Reporting Services 2005, but I don’t have an instance for that version handy at the moment to try it out. I think, from reading my prior post, that it worked in either mode, but I can’t prove it at the moment!) In other words, I can’t write the MDX manually in query mode – I must use the drag-and-drop interface to create my query. That’s fine for simple queries, but it won’t work when you need to add in calculations or otherwise make adjustments to the auto-generated query.</p>
<h5>The Complete Solution</h5>
<p>So once I switch the query to design mode like this:</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2011/03/SSASQuery.png"><img class="alignleft size-full wp-image-361" title="SSASQuery" src="http://blog.datainspirations.com/wp-content/uploads/2011/03/SSASQuery.png" alt="" width="443" height="331" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>And then preview the report, I now get the desired result.</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2011/03/Tablix3.png"><img class="alignleft size-full wp-image-360" title="Tablix3" src="http://blog.datainspirations.com/wp-content/uploads/2011/03/Tablix3.png" alt="" width="501" height="164" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>As I mentioned above, this will only work when the query is in design more. And there’s another requirement&#8211;the tablix must have at least one group defined. The benefit, though, is a faster report than you’ll get from running a comparable relational query. You won’t notice the difference in the AdventureWorks databases, but in that case, Reporting Services will perform aggregate functions reasonably well anyway. But if your data source has high volumes of data, then using a combination of cubes and Reporting Services will deliver much faster reports.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.datainspirations.com/2011/03/08/retrieving-aggregate-data/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Working with Reporting Services Filters&#8211;Part 5: OR Logic</title>
		<link>http://blog.datainspirations.com/2011/02/04/working-with-reporting-services-filterspart-5-or-logic/</link>
		<comments>http://blog.datainspirations.com/2011/02/04/working-with-reporting-services-filterspart-5-or-logic/#comments</comments>
		<pubDate>Fri, 04 Feb 2011 17:25:44 +0000</pubDate>
		<dc:creator>Stacia Misner</dc:creator>
				<category><![CDATA[Reporting Services]]></category>
		<category><![CDATA[filters]]></category>
		<category><![CDATA[SSRS]]></category>

		<guid isPermaLink="false">http://blog.datainspirations.com/2011/02/04/working-with-reporting-services-filterspart-5-or-logic/</guid>
		<description><![CDATA[When you combine multiple filters, Reporting Services uses AND logic. Once upon a time, there was actually a drop-down list for selecting AND or OR between filters which was very confusing to people because often it was grayed out. Now that selection is gone, but no matter. It wouldn’t help us solve the problem that [...]]]></description>
			<content:encoded><![CDATA[<p>When you combine multiple filters, Reporting Services uses AND logic. Once upon a time, there was actually a drop-down list for selecting AND or OR between filters which was very confusing to people because often it was grayed out. Now that selection is gone, but no matter. It wouldn’t help us solve the problem that I want to describe today. </p>
<p>As with many problems, Reporting Services gives us more than one way to apply OR logic in a filter. If I want a filter to include this value OR that value for the same field, one approach is to set up the filter is to use the IN operator as I explained in <a href="http://blog.datainspirations.com/2010/12/21/working-with-reporting-services-filterspart-1/" target="_blank">Part 1 of this series</a>. But what if I want to base the filter on two different fields? I&#160; need a different solution.</p>
<p>Using the AdventureWorksDW2008R2 database, I have a report that lists product sales:</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/9fc8d74fee11_6EBA/SNAGHTML139a4b29.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="SNAGHTML139a4b29" border="0" alt="SNAGHTML139a4b29" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/9fc8d74fee11_6EBA/SNAGHTML139a4b29_thumb.png" width="603" height="481" /></a></p>
<p>Let’s say that I want to filter this report to show only products that are Bikes (a category) OR products for which sales were greater than $1,000 in a year. </p>
<p>If I set up the filter like this:</p>
<table border="1" cellspacing="0" cellpadding="2" width="611">
<tbody>
<tr>
<td valign="top" width="101"><strong>Expression</strong></td>
<td valign="top" width="95"><strong>Data Type</strong></td>
<td valign="top" width="99"><strong>Operator</strong></td>
<td valign="top" width="314"><strong>Value</strong></td>
</tr>
<tr>
<td valign="top" width="102">[Category]</td>
<td valign="top" width="94">Text</td>
<td valign="top" width="100">=</td>
<td valign="top" width="314">Bikes</td>
</tr>
<tr>
<td valign="top" width="102">[SalesAmount]</td>
<td valign="top" width="94">&#160;</td>
<td valign="top" width="100">&gt;</td>
<td valign="top" width="314">1000</td>
</tr>
</tbody>
</table>
<p>Then AND logic is used which means that both conditions must be true. That’s not the result I want.</p>
<p>Instead, I need to set up the filter like this:</p>
<table border="1" cellspacing="0" cellpadding="2" width="611">
<tbody>
<tr>
<td valign="top" width="101"><strong>Expression</strong></td>
<td valign="top" width="95"><strong>Data Type</strong></td>
<td valign="top" width="99"><strong>Operator</strong></td>
<td valign="top" width="314"><strong>Value</strong></td>
</tr>
<tr>
<td valign="top" width="102">=Fields!EnglishProductCategoryName.Value = &quot;Bikes&quot; OR Fields!SalesAmount.Value &gt; 1000</td>
<td valign="top" width="94">Boolean</td>
<td valign="top" width="100">=</td>
<td valign="top" width="314">=True</td>
</tr>
</tbody>
</table>
<p>The OR logic needs to be part of the expression so that it can return a Boolean value that we test against the Value. Notice that I have used =True rather than True for the value. The filtered report appears below. Any non-bike product appears only if the total sales exceed $1,000, whereas Bikes appear regardless of sales. (You can’t see it in this screenshot, but Mountain-400-W Silver, 38 has sales of $923 in 2007 but gets included because it is in the Bikes category.) </p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/9fc8d74fee11_6EBA/SNAGHTML13b7749a.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="SNAGHTML13b7749a" border="0" alt="SNAGHTML13b7749a" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/9fc8d74fee11_6EBA/SNAGHTML13b7749a_thumb.png" width="631" height="504" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.datainspirations.com/2011/02/04/working-with-reporting-services-filterspart-5-or-logic/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Case of the Missing Date/Time Stamp: Reporting Services 2008 R2 Snapshots</title>
		<link>http://blog.datainspirations.com/2011/01/25/the-case-of-the-missing-datetime-stamp-reporting-services-2008-r2-snapshots/</link>
		<comments>http://blog.datainspirations.com/2011/01/25/the-case-of-the-missing-datetime-stamp-reporting-services-2008-r2-snapshots/#comments</comments>
		<pubDate>Tue, 25 Jan 2011 23:12:37 +0000</pubDate>
		<dc:creator>Stacia Misner</dc:creator>
				<category><![CDATA[Reporting Services]]></category>
		<category><![CDATA[SQL Server 2008 R2]]></category>
		<category><![CDATA[SSRS]]></category>

		<guid isPermaLink="false">http://blog.datainspirations.com/2011/01/25/the-case-of-the-missing-datetime-stamp-reporting-services-2008-r2-snapshots/</guid>
		<description><![CDATA[This week I stumbled upon an undocumented “feature” in SQL Server 2008 R2 Reporting Services as I was preparing a demonstration on how to set up and use report snapshots. If you’re familiar with the main changes in this latest release of Reporting Services, you probably already know that Report Manager got a facelift this [...]]]></description>
			<content:encoded><![CDATA[<p>This week I stumbled upon an undocumented “feature” in SQL Server 2008 R2 Reporting Services as I was preparing a demonstration on how to set up and use report snapshots. If you’re familiar with the main changes in this latest release of Reporting Services, you probably already know that Report Manager got a facelift this time around. Although this facelift was generally a good thing, one of the casualties – in my opinion – is the loss of the snapshot label that served two purposes… First, it flagged the report as a snapshot. Second, it let you know when that snapshot was created.</p>
<p>As part of my standard operating procedure when demonstrating report snapshots, I point out this label, so I was rather taken aback when I didn’t see it in the demonstration I was preparing. It sort of upset my routine, and I’m rather partial to my routines. I thought perhaps I wasn’t looking in the right place and changed Report Manager from Tile View to Detail View, but no – that label was still missing. In the grand scheme of life, it’s not an earth-shattering change, but you’ll have to look at the Modified Date in Details View to know when the snapshot was run. Or hope that the report developer included a textbox to show the execution time in the report. (Hint: this is a good time to add this to your list of report development best practices, whether a report gets set up as a report snapshot or not!) </p>
<p><strong>A snapshot from the past</strong></p>
<p>In case you don’t remember how a snapshot appeared in Report Manager back in the old days (of SQL Server 2008 and earlier), here’s an image I snagged from my <a href="http://www.amazon.com/Microsoft-Server-2008-Reporting-Services/dp/0735626472/ref=sr_1_1?ie=UTF8&amp;qid=1295996994&amp;sr=8-1" target="_blank">Reporting Services 2008 Step by Step</a> manuscript:</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/82855fa73126_CF9E/clip_image001.gif"><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="clip_image001" border="0" alt="clip_image001" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/82855fa73126_CF9E/clip_image001_thumb.gif" width="244" height="52" /></a></p>
<p><strong>A snapshot in the present</strong></p>
<p>A report server running in SharePoint integrated mode had no such label. There you had to rely on the Report Modified date-time stamp to know the snapshot execution time. So I guess all platforms are now consistent. </p>
<p>Here’s a screenshot of Report Manager in the 2008 R2 version. One of these is a snapshot and the rest execute on demand. Can you tell which is the snapshot?</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/82855fa73126_CF9E/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://blog.datainspirations.com/wp-content/uploads/2010/11/82855fa73126_CF9E/image_thumb.png" width="475" height="208" /></a></p>
<p><strong>Consider descriptions as an alternative</strong></p>
<p>So my report snapshot demonstration has one less step, and I’ll need to edit the Denali version of the Step by Step book. Things are simpler this way, but I sure wish we had an easier way to identify the execution methods of the reports. Consider using the description field to alert users that the report is a snapshot. It might save you a few questions about why the data isn’t up-to-date if the users know that something changed in the source of the report. Notice that the full description doesn’t display in Tile View, so keep it short and sweet or instruct users to open Details View to see the entire description.</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/82855fa73126_CF9E/image_3.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://blog.datainspirations.com/wp-content/uploads/2010/11/82855fa73126_CF9E/image_thumb_3.png" width="474" height="206" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.datainspirations.com/2011/01/25/the-case-of-the-missing-datetime-stamp-reporting-services-2008-r2-snapshots/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Working with Reporting Services Filters &#8211; Part 4: Creating a NOT IN Filter</title>
		<link>http://blog.datainspirations.com/2011/01/20/working-with-reporting-services-filters-part-4-creating-a-not-in-filter/</link>
		<comments>http://blog.datainspirations.com/2011/01/20/working-with-reporting-services-filters-part-4-creating-a-not-in-filter/#comments</comments>
		<pubDate>Thu, 20 Jan 2011 18:28:38 +0000</pubDate>
		<dc:creator>Stacia Misner</dc:creator>
				<category><![CDATA[Reporting Services]]></category>
		<category><![CDATA[filters]]></category>
		<category><![CDATA[SSRS]]></category>

		<guid isPermaLink="false">http://blog.datainspirations.com/2011/01/20/working-with-reporting-services-filters-part-4-creating-a-not-in-filter/</guid>
		<description><![CDATA[A question came in from a reader asking about how to create a NOT IN filter. You can see in the first of this series of blog posts about Reporting Services filters, NOT IN is not available in our list of operators for filters. However, it&#8217;s still possible to produce a filter that excludes items [...]]]></description>
			<content:encoded><![CDATA[<p>A question came in from a reader asking about how to create a NOT IN filter. You can see in the <a href="http://blog.datainspirations.com/2010/12/21/working-with-reporting-services-filterspart-1/" target="_blank">first of this series of blog posts about Reporting Services filters</a>, NOT IN is not available in our list of operators for filters. However, it&#8217;s still possible to produce a filter that excludes items in the list. The technique is not particularly intuitive, which is why I&#8217;ve added this filter type to my series on filters.</p>
<p><strong>Preparing the Report</strong></p>
<p>Let&#8217;s start with a simple scenario using the <a href="http://msftdbprodsamples.codeplex.com/releases/view/55926" target="_blank">AdventureWorksDW2008R2 database</a>. I set up a query that returns reseller sales by category. In my report, I have two tables: one for Bikes and Components, and the other for everything else. I want to create a filter for the first table using the IN operator, but I&#8217;ll have to create an expression for the second table to achieve the NOT IN effect.</p>
<p>To hold the list of values for my IN filter, I create a hidden report parameter with multi-values, without available values, and with a list of default values that includes Bikes and Components, like this:</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/382bd4da32c5_7654/image.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/382bd4da32c5_7654/image_thumb.png" border="0" alt="image" width="390" height="319" /></a> <a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/382bd4da32c5_7654/image_3.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/382bd4da32c5_7654/image_thumb_3.png" border="0" alt="image" width="390" height="319" /></a></p>
<p>Of course, I don&#8217;t need to manually populate the default values. I could use a query instead, but I think you get the idea.</p>
<p><strong>Using the IN Operator</strong></p>
<p>This step is not really required to set up the NOT IN filter, but I have included it as another example of working with the IN operator to supplement my first post in this series. In my report, I want the first table to include the values that are defined in the parameter, so I add a filter to the tablix like this:</p>
<table border="1" cellspacing="0" cellpadding="2" width="590">
<tbody>
<tr>
<td width="158" valign="top"><strong>Expression</strong></td>
<td width="113" valign="top"><strong>Data Type</strong></td>
<td width="56" valign="top"><strong>Operator</strong></td>
<td width="261" valign="top"><strong>Value</strong></td>
</tr>
<tr>
<td width="158" valign="top">[Category]</td>
<td width="113" valign="top">Text</td>
<td width="56" valign="top">In</td>
<td width="261" valign="top">=Parameters!FilterList.Value</td>
</tr>
</tbody>
</table>
<p>You can also use [@FilterList] as the value if you want to type in a simple expression into the Value field. If you use the Expression Editor to set up the Value expression, and double-click on FilterList in the Parameters category, be sure to remove the <strong>(0)</strong> from the end of the expression so that the IN operator is comparing Category to all values in the parameter array, not just the first value.</p>
<p><strong>Creating a NOT IN Filter</strong></p>
<p>For the second table, I also add a filter, but I set it up differently. There is no such thing as a NOT IN operator, so I need to get creative. I need to come up with an expression that evaluates as True or False, and then set that up as my Value in the filter definition. Then I’ll set the Expression of the filter to True and use an = operator. The filter will keep rows where Value is True and exclude rows which cause Value to be False.</p>
<table border="1" cellspacing="0" cellpadding="2" width="616">
<tbody>
<tr>
<td width="89" valign="top"><strong>Expression</strong></td>
<td width="81" valign="top"><strong>Data Type</strong></td>
<td width="70" valign="top"><strong>Operator</strong></td>
<td width="374" valign="top"><strong>Value</strong></td>
</tr>
<tr>
<td width="89" valign="top">=True</td>
<td width="81" valign="top">Boolean</td>
<td width="70" valign="top">=</td>
<td width="374" valign="top">=Iif(InStr(Join(Parameters!FilterList.Value,&#8221;,&#8221;),<br />
Fields!Category.Value)=0,True,False)</td>
</tr>
</tbody>
</table>
<p>For Expression, note that I have =True and not just True. This is important because True by itself will be interpreted as a string instead of a Boolean data type.</p>
<p>I use the InStr function in the value to compare the current row’s Category to the FilterList which I convert from an array to a comma-delimited string by using the Join function. The InStr function returns 0 if the category is not found, which is the equivalent of NOT IN. Thus, I have the expression return a True – which keeps the row in the second table.</p>
<p><strong>Checking the Results</strong></p>
<p>Here’s the final report:</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/382bd4da32c5_7654/image_4.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/382bd4da32c5_7654/image_thumb_4.png" border="0" alt="image" width="518" height="100" /></a></p>
<p>If you’d like to have a look at how I set this up, you can <a href="http://blog.datainspirations.com/uploads/in-vs-not-in.zip" target="_blank">download the RDL</a>.</p>
<p>Have you found another way to solve NOT IN? Let me know!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.datainspirations.com/2011/01/20/working-with-reporting-services-filters-part-4-creating-a-not-in-filter/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Working with Reporting Services Filters &#8211; Part 3: The TOP and BOTTOM Operators</title>
		<link>http://blog.datainspirations.com/2011/01/07/working-with-reporting-services-filters-part-3-the-top-and-bottom-operators/</link>
		<comments>http://blog.datainspirations.com/2011/01/07/working-with-reporting-services-filters-part-3-the-top-and-bottom-operators/#comments</comments>
		<pubDate>Fri, 07 Jan 2011 23:06:03 +0000</pubDate>
		<dc:creator>Stacia Misner</dc:creator>
				<category><![CDATA[Reporting Services]]></category>
		<category><![CDATA[filters]]></category>
		<category><![CDATA[SSRS]]></category>

		<guid isPermaLink="false">http://blog.datainspirations.com/2011/01/07/working-with-reporting-services-filters-part-3-the-top-and-bottom-operators/</guid>
		<description><![CDATA[Thus far in this series, I have described using the IN operator and the LIKE operator. Today, I’ll continue the series by reviewing the TOP and BOTTOM operators. Today, I happened to be working on an example of using the TOP N operator and was not successful on my first try because the behavior is [...]]]></description>
			<content:encoded><![CDATA[<p>Thus far in this series, I have described using the <a href="http://blog.datainspirations.com/2010/12/21/working-with-reporting-services-filterspart-1/" target="_blank">IN operator</a> and the <a href="http://blog.datainspirations.com/2010/12/30/working-with-reporting-services-filters-part-2-the-like-operator/" target="_blank">LIKE operator</a>. Today, I’ll continue the series by reviewing the TOP and BOTTOM operators.</p>
<p>Today, I happened to be working on an example of using the TOP N operator and was not successful on my first try because the behavior is just a bit different than we find when using an “equals” comparison as I described in <a href="http://blog.datainspirations.com/2010/12/21/working-with-reporting-services-filterspart-1/" target="_blank">my first post in this series</a>. In my example, I wanted to display a list of the top 5 resellers in the United States for AdventureWorks, but I wanted it based on a filter. I started with a hard-coded filter like this:</p>
<table border="1" cellspacing="0" cellpadding="2" width="399">
<tbody>
<tr>
<td width="158" valign="top"><strong>Expression</strong></td>
<td width="113" valign="top"><strong>Data Type</strong></td>
<td width="56" valign="top"><strong>Operator</strong></td>
<td width="70" valign="top"><strong>Value</strong></td>
</tr>
<tr>
<td width="158" valign="top">[ResellerSalesAmount]</td>
<td width="113" valign="top">Float</td>
<td width="56" valign="top">Top N</td>
<td width="70" valign="top">5</td>
</tr>
</tbody>
</table>
<p>And received the following error:</p>
<p><span style="color: #a5a5a5;">A filter value in the filter for tablix &#8216;Tablix1&#8242; specifies a data type that is not supported by the &#8216;TopN&#8217; operator. Verify that the data type for each filter value is Integer.</span></p>
<p>Well, that puzzled me. Did I really have to convert ResellerSalesAmount to an integer to use the Top N operator?</p>
<p>Just for kicks, I switched to the Top % operator like this:</p>
<table border="1" cellspacing="0" cellpadding="2" width="399">
<tbody>
<tr>
<td width="158" valign="top"><strong>Expression</strong></td>
<td width="113" valign="top"><strong>Data Type</strong></td>
<td width="56" valign="top"><strong>Operator</strong></td>
<td width="70" valign="top"><strong>Value</strong></td>
</tr>
<tr>
<td width="158" valign="top">[ResellerSalesAmount]</td>
<td width="113" valign="top">Float</td>
<td width="56" valign="top">Top %</td>
<td width="70" valign="top">50</td>
</tr>
</tbody>
</table>
<p>This time, I got exactly the results I expected – I had a total of 10 records in my dataset results, so 50% of that should yield 5 rows in my tablix.</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/Working-with-Reporting-Services-Filters-_CBD1/image.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/Working-with-Reporting-Services-Filters-_CBD1/image_thumb.png" border="0" alt="image" width="390" height="129" /></a></p>
<p>So thinking about the problem with Top N some  more, I switched the Value to an expression, like this:</p>
<table border="1" cellspacing="0" cellpadding="2" width="399">
<tbody>
<tr>
<td width="158" valign="top"><strong>Expression</strong></td>
<td width="113" valign="top"><strong>Data Type</strong></td>
<td width="56" valign="top"><strong>Operator</strong></td>
<td width="70" valign="top"><strong>Value</strong></td>
</tr>
<tr>
<td width="158" valign="top">[ResellerSalesAmount]</td>
<td width="113" valign="top">Float</td>
<td width="56" valign="top">Top N</td>
<td width="70" valign="top">=5</td>
</tr>
</tbody>
</table>
<p>And it worked!</p>
<p>So the value for Top N or Top % must reflect a number to plug into the calculation, such as Top 5 or Top 50%, and the expression is the basis for determining what’s in that group. In other words, Reporting Services will sort the rows by the expression – ResellerSalesAmount in this case – in descending order, and then filter out everything except the topmost rows based on the operator you specify.</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/Working-with-Reporting-Services-Filters-_CBD1/image_3.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/Working-with-Reporting-Services-Filters-_CBD1/image_thumb_3.png" border="0" alt="image" width="488" height="198" /></a></p>
<p>The curious thing is that, if you’re going to hard-code the value, you must enter the value for Top N with an equal sign in front of the integer, but you can omit the equal sign when entering a hard-coded value for Top %. This experience is why working with Reporting Services filters is not always intuitive!</p>
<p>When you use a report parameter to set the value, you won’t have this problem. Just be sure that the data type of the report parameter is set to Integer. Jessica Moss has an example of using a Top N filter in a tablix which you can view <a href="http://jessicammoss.blogspot.com/2008/08/display-top-n-rows.html" target="_blank">here</a>.</p>
<p>Working with Bottom N and Bottom % works similarly. You just provide a number for N or for the percentage and Reporting Services works from the bottom up to determine which rows are kept and which are excluded.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.datainspirations.com/2011/01/07/working-with-reporting-services-filters-part-3-the-top-and-bottom-operators/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

