<?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>Jeremy Smyth's Blog &#187; SSRS</title>
	<atom:link href="http://jeremysmyth.com/tag/ssrs/feed/" rel="self" type="application/rss+xml" />
	<link>http://jeremysmyth.com</link>
	<description></description>
	<lastBuildDate>Tue, 10 Aug 2010 12:07:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Cascading Parameter Values in SSRS</title>
		<link>http://jeremysmyth.com/2010/03/06/cascading-parameter-values-in-ssrs/</link>
		<comments>http://jeremysmyth.com/2010/03/06/cascading-parameter-values-in-ssrs/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 15:25:38 +0000</pubDate>
		<dc:creator>Jeremy Smyth</dc:creator>
				<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SSRS]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://jeremysmyth.com/?p=192</guid>
		<description><![CDATA[In SQL Server Reporting Services (SSRS), you might want your choice in the first parameter to limit the choices available in the second (and subsequent) parameters.
This works automagically if you order your parameters and datasets correctly

First, set up a primary (report) dataset, then a dataset for each parameter dropdown. Code the WHERE clause in the [...]]]></description>
			<content:encoded><![CDATA[<p>In SQL Server Reporting Services (SSRS), you might want your choice in the first parameter to limit the choices available in the second (and subsequent) parameters.</p>
<p>This works automagically if you order your parameters and datasets correctly</p>
<ul>
<li>First, set up a primary (report) dataset, then a dataset for each parameter dropdown. Code the WHERE clause in the datasets to make the dependencies correct across parameter variables</li>
<li>Secondly, order your parameters in the Report | Parameters menu so that the first variable/parameter you want the user to fill in is at the top, and make the second dataset depend on that parameter. Follow this ordering through the parameters; the final parameter(s) should be the one(s) the actual report dataset depends on.</li>
<li>Repeat for subsequent parameters</li>
</ul>
<p>This will work if your WHERE clause in the second and subsequent datasets have variables that SSRS knows are populated from earlier parameters.</p>
<p>As an example, I have three datasets from the venerable pubs database.</p>
<p><tt>pubslist</tt> is used to populate the <tt>@p</tt> parameter, and looks like this:</p>
<pre>
<div class="codesnip-container" >
<div class="sql codesnip" style="font-family:monospace;"><span class="kw1">SELECT</span> pub_id<span class="sy0">,</span> pub_name <span class="kw1">FROM</span> publishers</div>
</div>
</pre>
<p><tt>titleslist</tt> populates the <tt>@t</tt> parameter, and looks like this:</p>
<pre>
<div class="codesnip-container" >
<div class="sql codesnip" style="font-family:monospace;"><span class="kw1">SELECT</span> title_id<span class="sy0">,</span> title <span class="kw1">FROM</span> titles <span class="kw1">WHERE</span> pub_id <span class="sy0">=</span> @p</div>
</div>
</pre>
<p>Finally, <tt>reportdataset</tt> looks like this:</p>
<pre>
<div class="codesnip-container" >
<div class="sql codesnip" style="font-family:monospace;"><span class="kw1">SELECT</span> title<span class="sy0">,</span> price<span class="sy0">,</span> ytd_sales <span class="kw1">FROM</span> titles <span class="kw1">WHERE</span> title_id <span class="sy0">=</span> @t</div>
</div>
</pre>
<p>The order of the parameters in the Report | Report Parameters menu is crucial; because the datasets must be executed in the order shown above, and the @t parameter is in a dataset that relies on the @p parameter being set first, we move @p to the top of the list.</p>
<p>Now, SSRS evaluates the dataset needed to fill the dropdown for the first parameter with labels. It relies on a dataset that doesn&#8217;t need a parameter, so can be produced immediately.</p>
<p>Then, having got that parameter value, it can populate the second parameter&#8217;s dropdown. That in turn results in the report being produced.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeremysmyth.com/2010/03/06/cascading-parameter-values-in-ssrs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
