<?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>Weng Kien&#039;s Blog</title>
	<atom:link href="http://www.wengkien.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.wengkien.com</link>
	<description>...Viva La Vida...</description>
	<lastBuildDate>Tue, 11 Oct 2011 09:30:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Different Between Where Clause and SubSelect Expression</title>
		<link>http://www.wengkien.com/2011/10/11/different-between-where-clause-and-subselect-expression/</link>
		<comments>http://www.wengkien.com/2011/10/11/different-between-where-clause-and-subselect-expression/#comments</comments>
		<pubDate>Tue, 11 Oct 2011 09:30:55 +0000</pubDate>
		<dc:creator>Kien</dc:creator>
				<category><![CDATA[MS Reporting Services]]></category>
		<category><![CDATA[MDX]]></category>

		<guid isPermaLink="false">http://www.wengkien.com/?p=360</guid>
		<description><![CDATA[Tried search up and down from google about the different between where clause and SubSelect expression in the MDX statement but i make me more blur about it. I do some R&#038;D on the [All] member and i found one different that i would like to share out. With &#8220;Where Clause&#8221; Statement SELECT { [Measures].[Sales [...]]]></description>
			<content:encoded><![CDATA[<p>Tried search up and down from google about the different between <strong>where clause</strong> and <strong>SubSelect expression</strong> in the MDX statement but i make me more blur about it. I do some R&#038;D on the [All] member and i found one different that i would like to share out.</p>
<p><Strong>With &#8220;Where Clause&#8221; Statement</strong><br />
<code><br />
SELECT<br />
{<br />
	[Measures].[Sales Amount]<br />
} ON COLUMNS,<br />
{<br />
	[Product].[Product Categories].[All]<br />
} ON ROWS<br />
FROM [Adventure Works]<br />
WHERE ({[Product].[Product Model Lines].[Model].MEMBERS -<br />
		[Product].[Product Model Lines].[Model].&#038;[Bike Wash] -<br />
		[Product].[Product Model Lines].[Model].&#038;[Cable Lock] -<br />
		[Product].[Product Model Lines].[Model].&#038;[Classic Vest]});<br />
</code></p>
<p>Return Result:<br />
<a href="http://www.wengkien.com/wp-content/uploads/2011/10/where_clause.bmp"><img src="http://www.wengkien.com/wp-content/uploads/2011/10/where_clause.bmp" alt="" title="where_clause" class="alignnone size-full wp-image-363" /></a></p>
<p><strong>With &#8220;SubSelect&#8221; Statement</strong><br />
<code><br />
SELECT {<br />
	[Measures].[Sales Amount]<br />
} ON COLUMNS,<br />
{<br />
	[Product].[Product Categories].[All]<br />
} ON ROWS<br />
FROM (<br />
		SELECT {[Product].[Product Model Lines].[Model].MEMBERS -<br />
				[Product].[Product Model Lines].[Model].&#038;[Bike Wash] -<br />
				[Product].[Product Model Lines].[Model].&#038;[Cable Lock] -<br />
				[Product].[Product Model Lines].[Model].&#038;[Classic Vest]} ON COLUMNS<br />
		FROM [Adventure Works]<br />
	 );<br />
</code></p>
<p>Return Result:<br />
<a href="http://www.wengkien.com/wp-content/uploads/2011/10/subselect_statement.bmp"><img src="http://www.wengkien.com/wp-content/uploads/2011/10/subselect_statement.bmp" alt="" title="subselect_statement" class="alignnone size-full wp-image-365" /></a></p>
<p><strong>Comparison about both statement</strong><br />
You can see both statement return different result and the different is $294,120.56. When system pulling the [Product].[Product Categories].[All] for the &#8220;where clause&#8221;, it didn&#8217;t adjusted the [All] member value to the filtered context. But the &#8220;Subselect statement&#8221; was adjusted based on the filtered context.</p>
<p><strong>Filtered members value</strong><br />
<code><br />
SELECT<br />
{<br />
	[Measures].[Sales Amount]<br />
} ON COLUMNS,<br />
{<br />
	[Product].[Product Model Lines].[Model].&#038;[Bike Wash],<br />
	[Product].[Product Model Lines].[Model].&#038;[Cable Lock],<br />
	[Product].[Product Model Lines].[Model].&#038;[Classic Vest]<br />
} ON ROWS<br />
FROM [Adventure Works];<br />
</code></p>
<p>Return Result: Total = $294,120.56.<br />
<a href="http://www.wengkien.com/wp-content/uploads/2011/10/total_members.bmp"><img src="http://www.wengkien.com/wp-content/uploads/2011/10/total_members.bmp" alt="" title="total_members" class="alignnone size-full wp-image-367" /></a></p>
<p><strong> Conclusion </strong><br />
Now you will get more clear picture about the [All] member for &#8220;where clause&#8221; still refer to the unfiltered members but &#8220;subselect statement&#8221; will refer to subcube that already filtered out the members. </p>
<p>Will put in more differences in future.</p>
<p>To run the sample code, you must install the <a href="http://msftdbprodsamples.codeplex.com/releases/view/37109">AdventureWorks</a> sample.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wengkien.com/2011/10/11/different-between-where-clause-and-subselect-expression/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

