<?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>Purple Frog Systems</title>
	<atom:link href="http://www.purplefrogsystems.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.purplefrogsystems.com/blog</link>
	<description>Business Intelligence Consultancy</description>
	<lastBuildDate>Mon, 13 May 2013 13:42:19 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>SQL Relay 2013</title>
		<link>http://www.purplefrogsystems.com/blog/2013/05/sql-relay-2013/</link>
		<comments>http://www.purplefrogsystems.com/blog/2013/05/sql-relay-2013/#comments</comments>
		<pubDate>Mon, 13 May 2013 13:42:19 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[SQL Relay]]></category>

		<guid isPermaLink="false">http://www.purplefrogsystems.com/blog/?p=685</guid>
		<description><![CDATA[SQL Relay 2013 is only a month away! If you&#8217;ve not signed up yet to SQL Relay 2013 then you&#8217;d better get in there quick, as 2 of the 8 events are already full&#8230; What is SQL Relay? A series of 8 SQL Server conferences around the UK, held between 17th June and 27th June. [...]]]></description>
				<content:encoded><![CDATA[<h1>SQL Relay 2013 is only a month away!<a title="SQL Relay" href="http://www.SQLRelay.co.uk"><img class="alignright size-full wp-image-686" alt="SQL Relay 2013" src="http://www.purplefrogsystems.com/blog/wp-content/uploads/2013/05/SQLRelay2013_300_trans.png" width="300" height="105" /></a></h1>
<p>If you&#8217;ve not signed up yet to SQL Relay 2013 then you&#8217;d better get in there quick, as 2 of the 8 events are already full&#8230;</p>
<h3>What is SQL Relay?</h3>
<p>A series of 8 SQL Server conferences around the UK, held between 17th June and 27th June. They are FREE to attend (thanks to the generous sponsors!), and each contains a full day of technical talks covering different aspects of SQL Server.</p>
<h3>Who&#8217;s speaking?</h3>
<p>Numerous experts from Microsoft (from the UK and the USA), and more SQL Server MVPs and renowned authors than you can shake a large stick at! These include Kevin Kline, Grant Fritchey, Scott Klein, Andrew Fryer, Jen Stirrup, Chris Webb and loads more. If you don&#8217;t know who these people are, then you need to come along and find out! By all means bring any of their books for a personal signing <img src='http://www.purplefrogsystems.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The Microsoft SQL Server Product Managers in the UK are presenting the keynote at each event.</p>
<h3>Where are they?</h3>
<p>All over the UK. Find your nearest event here:</p>
<p><img class="alignright size-full wp-image-687" alt="SQL Relay 2013 Map" src="http://www.purplefrogsystems.com/blog/wp-content/uploads/2013/05/SQLRelay-2013-Map_250.png" width="250" height="313" /></p>
<table id="agendatable">
<thead>
<tr>
<th colspan="3">Event Schedule</th>
</tr>
<tr>
<th>Details</th>
<th>Date</th>
<th>Register</th>
</tr>
</thead>
<tbody>
<tr>
<td>Glasgow</td>
<td>Monday 17th June 2013</td>
<td style="text-align: center;"><a href="http://sqlserverfaq.com/?eid=510">Register</a></td>
</tr>
<tr>
<td>Leeds</td>
<td>Tuesday 18th June 2013</td>
<td style="text-align: center;"><a href="http://sqlserverfaq.com/?eid=511">Register</a></td>
</tr>
<tr>
<td>Birmingham</td>
<td>Wednesday 19th June 2013</td>
<td style="text-align: center;"><a href="http://sqlserverfaq.com/?eid=512">Register</a></td>
</tr>
<tr>
<td>Norwich</td>
<td>Thursday 20th June 2013</td>
<td style="text-align: center;"><a href="http://sqlserverfaq.com/?eid=513">Register</a></td>
</tr>
<tr>
<td colspan="3"></td>
</tr>
<tr>
<td>Cardiff</td>
<td>Monday 24th June 2013</td>
<td style="text-align: center;"><a href="http://sqlserverfaq.com/?eid=514">Register</a></td>
</tr>
<tr>
<td>Southampton</td>
<td>Tuesday 25th June 2013</td>
<td style="text-align: center;"><a href="http://sqlserverfaq.com/?eid=515">Register</a></td>
</tr>
<tr>
<td>Reading</td>
<td>Wednesday 26th June 2013</td>
<td style="text-align: center;"><a href="http://sqlserverfaq.com/?eid=516">Register</a></td>
</tr>
<tr>
<td>London</td>
<td>Thursday 27th June 2013</td>
<td style="text-align: center;"><a href="http://sqlserverfaq.com/?eid=517">Register</a></td>
</tr>
</tbody>
</table>
<h3>How do you register?</h3>
<p>Using the links above!</p>
<h3>Where do you find out more?</h3>
<p>You can check out photos and details of last year&#8217;s Relay events at <a href="http://www.SQLRelay.co.uk">www.SQLRelay.co.uk</a></p>
<p>Or click on the link above for each venue to check out the line-up and to register</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.purplefrogsystems.com/blog/2013/05/sql-relay-2013/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MDX Between Start Date and End Date</title>
		<link>http://www.purplefrogsystems.com/blog/2013/04/mdx-between-start-date-and-end-date/</link>
		<comments>http://www.purplefrogsystems.com/blog/2013/04/mdx-between-start-date-and-end-date/#comments</comments>
		<pubDate>Sun, 14 Apr 2013 17:27:30 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Analysis Services]]></category>
		<category><![CDATA[MDX]]></category>

		<guid isPermaLink="false">http://www.purplefrogsystems.com/blog/?p=667</guid>
		<description><![CDATA[How do you use MDX to find the number of items between two dates, when the start date and end date are different role playing dimensions? I had an interesting question from Ricardo Santos on another frog-blog post this week (MDX Calculated Member spanning multiple date dimensions). I answered Ricardo in the post, but it [...]]]></description>
				<content:encoded><![CDATA[<p>How do you use MDX to find the number of items between two dates, when the start date and end date are different role playing dimensions?</p>
<p>I had an interesting question from Ricardo Santos on another frog-blog post this week (<a href="/blog/2010/08/mdx-calculated-member-spanning-multiple-date-dimensions/">MDX Calculated Member spanning multiple date dimensions</a>). I answered Ricardo in the post, but it was a good question which I thought deserved a full blog post on its own. So thanks to Ricardo for prompting this.</p>
<h2>The Scenario</h2>
<p>If you have a &#8216;Project&#8217; fact table, which has two dates (start date and end date), how do you find out how many projects are active on any given date. In this scenario we would have three role playing date dimensions; Date, Start Date &#038; End Date. </p>
<p>We want the user to be able to select a date (from the Date dimension) and then use that to filter the projects using the other two date dimensions.</p>
<p>This also applies to many other scenarios; accomodation occupancy, staffing levels, contracts, really anything with a start and end date.</p>
<h2>The MDX answer</h2>
<p>If there was just a single date dimension (i.e. a typical sales fact) then you could just filter it</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="sql" style="font-family:monospace;">  <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span>Measures<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Internet Sales Amount<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">,</span> <span style="color: #66cc66;">&#91;</span><span style="color: #993333; font-weight: bold;">DATE</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Calendar<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span>&amp;<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">20080110</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span></pre></td></tr></table></div>

<p>But what we need to do is combine two different date dimensions. In SQL, to find the number of active projects on 1st April 2013 we&#8217;d just use</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="sql" style="font-family:monospace;">   <span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #993333; font-weight: bold;">COUNT</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#41;</span>
   <span style="color: #993333; font-weight: bold;">FROM</span> Projects
   <span style="color: #993333; font-weight: bold;">WHERE</span> StartDate <span style="color: #66cc66;">&gt;=</span> <span style="color: #cc66cc;">20130401</span>
     <span style="color: #993333; font-weight: bold;">AND</span> EndDate   <span style="color: #66cc66;">&lt;=</span> <span style="color: #cc66cc;">20130401</span></pre></td></tr></table></div>

<p>The equivalent in MDX is more complex as we have to filter a fact by two different dimensions. Starting with the [Start Date] dimension, we need to sum the project count for the projects with a start date on or before the required date:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="sql" style="font-family:monospace;">    AGGREGATE<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span><span style="color: #993333; font-weight: bold;">NULL</span>:<span style="color: #66cc66;">&#91;</span><span style="color: #993333; font-weight: bold;">START</span> <span style="color: #993333; font-weight: bold;">DATE</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Calendar<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">20130401</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">,</span> <span style="color: #66cc66;">&#91;</span>Measures<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Project <span style="color: #993333; font-weight: bold;">COUNT</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span></pre></td></tr></table></div>

<p>We also need to then find the project count for all projects with an end date on or after the required date</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="sql" style="font-family:monospace;">    AGGREGATE<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#91;</span><span style="color: #993333; font-weight: bold;">END</span> <span style="color: #993333; font-weight: bold;">DATE</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Calendar<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">20130401</span><span style="color: #66cc66;">&#93;</span>:<span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">,</span> <span style="color: #66cc66;">&#91;</span>Measures<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Project <span style="color: #993333; font-weight: bold;">COUNT</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span></pre></td></tr></table></div>

<p>We can then use crossjoin (*) to combine them together.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="sql" style="font-family:monospace;">    AGGREGATE<span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #993333; font-weight: bold;">NULL</span>:<span style="color: #66cc66;">&#91;</span><span style="color: #993333; font-weight: bold;">START</span> <span style="color: #993333; font-weight: bold;">DATE</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Calendar<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">20130301</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#125;</span>
             <span style="color: #66cc66;">*</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#91;</span><span style="color: #993333; font-weight: bold;">END</span> <span style="color: #993333; font-weight: bold;">DATE</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Calendar<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">20130301</span><span style="color: #66cc66;">&#93;</span>:<span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">&#125;</span>
             <span style="color: #66cc66;">,</span> <span style="color: #66cc66;">&#91;</span>Measures<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Project <span style="color: #993333; font-weight: bold;">COUNT</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span></pre></td></tr></table></div>

<p>Note that you could also use FILTER to achieve the same goal.</p>
<p>This will find the project count for a specific date, but we now need to make the date dynamic. We want the calculation to use a date selected by the user from a 3rd [Date] dimension, applying this date to the other two dimensions (start date &#038; end date).</p>
<p>Enter the LINKMEMBER function. This is a great tool in your MDX arsenal, allowing you to identify a member of one dimension from a selection in a different role playing dimension. e.g.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="sql" style="font-family:monospace;">     LINKMEMBER<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span><span style="color: #993333; font-weight: bold;">DATE</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Calendar<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">20130414</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">,</span> <span style="color: #66cc66;">&#91;</span><span style="color: #993333; font-weight: bold;">START</span> <span style="color: #993333; font-weight: bold;">DATE</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Calendar<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span></pre></td></tr></table></div>

<p>The example above will return the following member of the Start Date dimension.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="sql" style="font-family:monospace;">     <span style="color: #66cc66;">&#91;</span><span style="color: #993333; font-weight: bold;">START</span> <span style="color: #993333; font-weight: bold;">DATE</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Calendar<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">20130414</span><span style="color: #66cc66;">&#93;</span></pre></td></tr></table></div>

<p>When we integrate this into the previous MDX, we get:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="sql" style="font-family:monospace;">    AGGREGATE<span style="color: #66cc66;">&#40;</span> 
          <span style="color: #66cc66;">&#123;</span><span style="color: #993333; font-weight: bold;">NULL</span>:LINKMEMBER<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span><span style="color: #993333; font-weight: bold;">DATE</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Calendar<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span>CURRENTMEMBER
                     <span style="color: #66cc66;">,</span><span style="color: #66cc66;">&#91;</span><span style="color: #993333; font-weight: bold;">START</span> <span style="color: #993333; font-weight: bold;">DATE</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Calendar<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">*</span> <span style="color: #66cc66;">&#123;</span>LINKMEMBER<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span><span style="color: #993333; font-weight: bold;">DATE</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Calendar<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span>CURRENTMEMBER
                    <span style="color: #66cc66;">,</span> <span style="color: #66cc66;">&#91;</span><span style="color: #993333; font-weight: bold;">END</span> <span style="color: #993333; font-weight: bold;">DATE</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Calendar<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">,</span> <span style="color: #66cc66;">&#91;</span>Measures<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Project <span style="color: #993333; font-weight: bold;">COUNT</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span></pre></td></tr></table></div>

<p>This will take the CURRENTMEMBER of the [Date].[Calendar] hierarchy, and map it to the equivalent members in the [Start Date].[Calendar] and [End Date].[Calendar] hierarchies, before then using the resulting members to filter the Project Count measure.</p>
<p>And there you have it.</p>
<p>But, that&#8217;s not strictly the right answer&#8230;</p>
<h2>Data modelling</h2>
<p>Whenever we have to write anything complicated in MDX, we need to ask ourselves the question of why?&#8230; Complicated MDX is all too often a symptom of poor data modelling. Usually caused when a data warehouse is designed with SQL in mind, not cubes/MDX. If you&#8217;re planning to use cubes then you can reap huge benefits from remodelling your data accordingly. This could be in your ETL and warehouse, or you can just remodel your data in the cube data source view. Lets have a look at an example.</p>
<p>The DSV for the project fact we were looking at earlier would be something like this (simplified)</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="sql" style="font-family:monospace;">    <span style="color: #993333; font-weight: bold;">SELECT</span> 
       <span style="color: #66cc66;">,</span> ProjectManagerKey
       <span style="color: #66cc66;">,</span> CustomerKey
       <span style="color: #66cc66;">,</span> StartDateKey
       <span style="color: #66cc66;">,</span> EndDateKey
       <span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">1</span> <span style="color: #993333; font-weight: bold;">AS</span> ProjectCount
    <span style="color: #993333; font-weight: bold;">FROM</span> FactProject</pre></td></tr></table></div>

<p>So the project fact represents a project. A cube fact table should however represent an event, not an item (items should be dimensions, not facts). So we need to think of a project as two seperate events; a start and an end. Take a look at the query below</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="sql" style="font-family:monospace;">    <span style="color: #993333; font-weight: bold;">SELECT</span> 
       <span style="color: #66cc66;">,</span> ProjectManagerKey
       <span style="color: #66cc66;">,</span> CustomerKey
       <span style="color: #66cc66;">,</span> StartDateKey <span style="color: #993333; font-weight: bold;">AS</span> DateKey
       <span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">1</span> <span style="color: #993333; font-weight: bold;">AS</span> ProjectCount
    <span style="color: #993333; font-weight: bold;">FROM</span> FactProject
	<span style="color: #993333; font-weight: bold;">UNION</span> <span style="color: #993333; font-weight: bold;">ALL</span>
    <span style="color: #993333; font-weight: bold;">SELECT</span> 
       <span style="color: #66cc66;">,</span> ProjectManagerKey
       <span style="color: #66cc66;">,</span> CustomerKey
       <span style="color: #66cc66;">,</span> EndDateKey <span style="color: #993333; font-weight: bold;">AS</span> DateKey
       <span style="color: #66cc66;">,</span> <span style="color: #66cc66;">-</span><span style="color: #cc66cc;">1</span> <span style="color: #993333; font-weight: bold;">AS</span> ProjectCount
    <span style="color: #993333; font-weight: bold;">FROM</span> FactProject</pre></td></tr></table></div>

<p>Each project will therefore exist twice, once with a +1 on the project start date, and once with a -1 on the project end date. And we only have a single date dimension to worry about.</p>
<h3>So how do we use this in MDX?</h3>
<p>You can find out the number of active projects on any given date using</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="sql" style="font-family:monospace;">    AGGREGATE<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span><span style="color: #993333; font-weight: bold;">NULL</span>:<span style="color: #66cc66;">&#91;</span><span style="color: #993333; font-weight: bold;">DATE</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Calendar<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span>CURRENTMEMBER<span style="color: #66cc66;">&#125;</span>
            <span style="color: #66cc66;">,</span> <span style="color: #66cc66;">&#91;</span>Measures<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Project <span style="color: #993333; font-weight: bold;">COUNT</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span></pre></td></tr></table></div>

<p>i.e. the sum of all projects started/finished prior to the selected date. </p>
<p>To find out the change in the number of projects in any given time period</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="sql" style="font-family:monospace;">    <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span><span style="color: #993333; font-weight: bold;">DATE</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Calendar<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span>CURRENTMEMBER
    <span style="color: #66cc66;">,</span><span style="color: #66cc66;">&#91;</span>Measures<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Project <span style="color: #993333; font-weight: bold;">COUNT</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span></pre></td></tr></table></div>

<p>In the SQL world this is an inefficient approach, but it&#8217;s perfectly suited to the way cubes work.</p>
<p>So by spending a little time thinking about the cube&#8217;s data model, we can dramatically simplify our MDX, and improve our performance.</p>
<p>Frog-blog out</p>
]]></content:encoded>
			<wfw:commentRss>http://www.purplefrogsystems.com/blog/2013/04/mdx-between-start-date-and-end-date/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Database Management PhD survey</title>
		<link>http://www.purplefrogsystems.com/blog/2012/12/database-management-phd-survey/</link>
		<comments>http://www.purplefrogsystems.com/blog/2012/12/database-management-phd-survey/#comments</comments>
		<pubDate>Tue, 18 Dec 2012 10:47:13 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.purplefrogsystems.com/blog/?p=659</guid>
		<description><![CDATA[If you&#8217;re involved in database management, can you spare 20 minutes to complete a survey? Victoria Holt is studying for her PhD, and would very much appreciate it if you could help her out with her survey. Go on&#8230; Fill it in whilst you have a break over a cup of tea &#038; a mince [...]]]></description>
				<content:encoded><![CDATA[<p>If you&#8217;re involved in database management, can you spare 20 minutes to complete a survey?</p>
<p>Victoria Holt is studying for her PhD, and would very much appreciate it if you could help her out with her survey.</p>
<p>Go on&#8230; Fill it in whilst you have a break over a cup of tea &#038; a mince pie&#8230;</p>
<p><a href="http://t.co/aekkOxYk">Full in the survey here</a></p>
<p>On behalf of Victoria, thanks</p>
]]></content:encoded>
			<wfw:commentRss>http://www.purplefrogsystems.com/blog/2012/12/database-management-phd-survey/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSIS Expression Editor and Tester</title>
		<link>http://www.purplefrogsystems.com/blog/2012/12/ssis-expression-editor-and-tester/</link>
		<comments>http://www.purplefrogsystems.com/blog/2012/12/ssis-expression-editor-and-tester/#comments</comments>
		<pubDate>Thu, 06 Dec 2012 12:18:54 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Integration Services]]></category>
		<category><![CDATA[Expressions]]></category>
		<category><![CDATA[SSIS]]></category>

		<guid isPermaLink="false">http://www.purplefrogsystems.com/blog/?p=652</guid>
		<description><![CDATA[I stumbled upon a gem of a tool this morning, written by Darren Green (blog &#124; twitter) of SQLBits &#38; Bids Helper fame; the SSIS Expression Editor and Tester. Kudos to Darren, this is a great little tool for fine tuning and testing those complex SSIS expressions without having to keep running tests within SSIS. [...]]]></description>
				<content:encoded><![CDATA[<p>I stumbled upon a gem of a tool this morning, written by Darren Green (<a href="http://www.sqlis.com/">blog </a>| <a href="https://twitter.com/sqlgreen">twitter</a>) of SQLBits &amp; Bids Helper fame; the <a href="http://expressioneditor.codeplex.com/">SSIS Expression Editor and Tester</a>.</p>
<p>Kudos to Darren, this is a great little tool for fine tuning and testing those complex SSIS expressions without having to keep running tests within SSIS. It&#8217;s downloadable with 3 versions, for SSIS 2005, 2008 &amp; 2012, and doesn&#8217;t even need installing, it just runs as an exe.</p>
<p>SSIS-tastic.</p>
<p><a href="http://expressioneditor.codeplex.com/"><img class="aligncenter size-full wp-image-653" title="SSISExpressionTester" src="http://www.purplefrogsystems.com/blog/wp-content/uploads/2012/12/SSISExpressionTester.png" alt="" width="725" height="534" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.purplefrogsystems.com/blog/2012/12/ssis-expression-editor-and-tester/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Querying dimension members in MDX</title>
		<link>http://www.purplefrogsystems.com/blog/2012/11/querying-dimension-members-in-mdx/</link>
		<comments>http://www.purplefrogsystems.com/blog/2012/11/querying-dimension-members-in-mdx/#comments</comments>
		<pubDate>Fri, 30 Nov 2012 16:27:04 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Analysis Services]]></category>
		<category><![CDATA[MDX]]></category>

		<guid isPermaLink="false">http://www.purplefrogsystems.com/blog/?p=635</guid>
		<description><![CDATA[Today we&#8217;re back looking at MDX with a quick how-to. How do you extract a list of dimension members using MDX? This could be used for example to populate a user interface/parameter of a report/dashboard. Let&#8217;s look at two scenarios; normal dimensions, and then hierarchies. All the queries here use the &#8220;Adventure Works DW 2008 [...]]]></description>
				<content:encoded><![CDATA[<p>Today we&#8217;re back looking at MDX with a quick how-to. How do you extract a list of dimension members using MDX?</p>
<p>This could be used for example to populate a user interface/parameter of a report/dashboard.</p>
<p>Let&#8217;s look at two scenarios; normal dimensions, and then hierarchies. All the queries here use the &#8220;Adventure Works DW 2008 R2&#8243; &#8220;Adventure Works&#8221; cube.</p>
<h2>Standard dimension attributes</h2>
<p>So how do we get a list of dimension members? Well lets divide the query up into rows and columns. We want the members listed on the rows.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span>
  xxx <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #993333; font-weight: bold;">COLUMNS</span><span style="color: #66cc66;">,</span>
  <span style="color: #66cc66;">&#91;</span>Geography<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Country<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span>ALLMEMBERS <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #993333; font-weight: bold;">ROWS</span>
<span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #66cc66;">&#91;</span>Adventure Works<span style="color: #66cc66;">&#93;</span></pre></td></tr></table></div>

<p>Why use .ALLMEMBERS instead of .MEMBERS? .ALLMEMBERS will include calculated members, whereas .MEMBERS won&#8217;t.</p>
<p>So what do we put on the rows? We want the display name for showing to the user, and the unique name so we can refer back to each exact member. We can get these by using properties of the current member, namely MEMBER_CAPTION and UNIQUENAME. Get a full list of <a href="http://msdn.microsoft.com/en-us/library/ms145528.aspx" target="_blank">dimension member properties here</a>. To make this work, we just define a number of query-scoped calculated members using WITH, and then include them in the columns set&#8230;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">WITH</span> 
   MEMBER <span style="color: #66cc66;">&#91;</span>Measures<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Label<span style="color: #66cc66;">&#93;</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #66cc66;">&#91;</span>Geography<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Country<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span>CURRENTMEMBER<span style="color: #66cc66;">.</span>MEMBER_CAPTION 
   MEMBER <span style="color: #66cc66;">&#91;</span>Measures<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>UniqueName<span style="color: #66cc66;">&#93;</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #66cc66;">&#91;</span>Geography<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Country<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span>CURRENTMEMBER<span style="color: #66cc66;">.</span>UNIQUENAME 
<span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#91;</span>Measures<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Label<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">,</span> 
        <span style="color: #66cc66;">&#91;</span>Measures<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>UniqueName<span style="color: #66cc66;">&#93;</span>
        <span style="color: #66cc66;">&#125;</span> <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #993333; font-weight: bold;">COLUMNS</span> <span style="color: #66cc66;">,</span> 
      <span style="color: #66cc66;">&#91;</span>Geography<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Country<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span>ALLMEMBERS <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #993333; font-weight: bold;">ROWS</span> 
<span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #66cc66;">&#91;</span>Adventure Works<span style="color: #66cc66;">&#93;</span></pre></td></tr></table></div>

<p>If you run this, you get the following output:<br />
<img class="aligncenter size-full wp-image-641" title="MDXDimensionMembers1" src="http://www.purplefrogsystems.com/blog/wp-content/uploads/2012/11/MDXDimensionMembers1.png" alt="" width="392" height="178" /><br />
This may be what you want, but note that the first row of the result set contains the &#8216;ALL&#8217; member, which you probably don&#8217;t want. You can remove this by altering the ROWS clause to exclude them. This is simply a case of repeating the hierarchy name, e.g. [Geography].[Country]<strong>.[Country]</strong>.ALLMEMBERS</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">WITH</span> 
   MEMBER <span style="color: #66cc66;">&#91;</span>Measures<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Label<span style="color: #66cc66;">&#93;</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #66cc66;">&#91;</span>Geography<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Country<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span>CURRENTMEMBER<span style="color: #66cc66;">.</span>MEMBER_CAPTION 
   MEMBER <span style="color: #66cc66;">&#91;</span>Measures<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>UniqueName<span style="color: #66cc66;">&#93;</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #66cc66;">&#91;</span>Geography<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Country<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span>CURRENTMEMBER<span style="color: #66cc66;">.</span>UNIQUENAME 
<span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#91;</span>Measures<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Label<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">,</span> 
        <span style="color: #66cc66;">&#91;</span>Measures<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>UniqueName<span style="color: #66cc66;">&#93;</span>
        <span style="color: #66cc66;">&#125;</span> <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #993333; font-weight: bold;">COLUMNS</span> <span style="color: #66cc66;">,</span> 
      <span style="color: #66cc66;">&#91;</span>Geography<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Country<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Country<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span>ALLMEMBERS <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #993333; font-weight: bold;">ROWS</span> 
<span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #66cc66;">&#91;</span>Adventure Works<span style="color: #66cc66;">&#93;</span></pre></td></tr></table></div>

<p><img src="http://www.purplefrogsystems.com/blog/wp-content/uploads/2012/11/MDXDimensionMembers2.png" alt="" title="MDXDimensionMembers2" width="392" height="134" class="aligncenter size-full wp-image-642" /></p>
<h2>Hierarchies</h2>
<p>With simple dimension attributes, you get a flat list of values. With hierarchies, whether standard user hierarchies, ragged or parent-child, you need to return a multi-level list. To do this we need to know what level each member is at. We can query this using the LEVEL.ORDINAL property. Adding this into the query, and replacing Geography for Employee, we get the following query:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">WITH</span> 
   MEMBER <span style="color: #66cc66;">&#91;</span>Measures<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Label<span style="color: #66cc66;">&#93;</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #66cc66;">&#91;</span>Employee<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Employees<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span>CURRENTMEMBER<span style="color: #66cc66;">.</span>MEMBER_CAPTION 
   MEMBER <span style="color: #66cc66;">&#91;</span>Measures<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>UniqueName<span style="color: #66cc66;">&#93;</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #66cc66;">&#91;</span>Employee<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Employees<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span>CURRENTMEMBER<span style="color: #66cc66;">.</span>UNIQUENAME 
   MEMBER <span style="color: #66cc66;">&#91;</span>Measures<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Ordinal<span style="color: #66cc66;">&#93;</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #66cc66;">&#91;</span>Employee<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Employees<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span>CURRENTMEMBER<span style="color: #66cc66;">.</span>LEVEL<span style="color: #66cc66;">.</span>ORDINAL 
<span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#91;</span>Measures<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Label<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">,</span> 
        <span style="color: #66cc66;">&#91;</span>Measures<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>UniqueName<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">,</span> 
        <span style="color: #66cc66;">&#91;</span>Measures<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Ordinal<span style="color: #66cc66;">&#93;</span>
        <span style="color: #66cc66;">&#125;</span> <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #993333; font-weight: bold;">COLUMNS</span> <span style="color: #66cc66;">,</span> 
      <span style="color: #66cc66;">&#91;</span>Employee<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Employees<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span>ALLMEMBERS <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #993333; font-weight: bold;">ROWS</span> 
<span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #66cc66;">&#91;</span>Adventure Works<span style="color: #66cc66;">&#93;</span></pre></td></tr></table></div>

<p>With the following results:<br />
<img src="http://www.purplefrogsystems.com/blog/wp-content/uploads/2012/11/MDXDimensionMembers3.png" alt="" title="MDXDimensionMembers3" width="607" height="468" class="aligncenter size-full wp-image-644" /></p>
<p>You can then do all sorts of funky things using basic MDX navigation functions. e.g. returning the parent of each member, by simply adding &#8230;PARENT.UNIQUENAME as another column</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">WITH</span> 
   MEMBER <span style="color: #66cc66;">&#91;</span>Measures<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Label<span style="color: #66cc66;">&#93;</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #66cc66;">&#91;</span>Employee<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Employees<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span>CURRENTMEMBER<span style="color: #66cc66;">.</span>MEMBER_CAPTION 
   MEMBER <span style="color: #66cc66;">&#91;</span>Measures<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>UniqueName<span style="color: #66cc66;">&#93;</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #66cc66;">&#91;</span>Employee<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Employees<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span>CURRENTMEMBER<span style="color: #66cc66;">.</span>UNIQUENAME 
   MEMBER <span style="color: #66cc66;">&#91;</span>Measures<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Ordinal<span style="color: #66cc66;">&#93;</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #66cc66;">&#91;</span>Employee<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Employees<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span>CURRENTMEMBER<span style="color: #66cc66;">.</span>LEVEL<span style="color: #66cc66;">.</span>ORDINAL 
   MEMBER <span style="color: #66cc66;">&#91;</span>Measures<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Parent<span style="color: #66cc66;">&#93;</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #66cc66;">&#91;</span>Employee<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Employees<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span>PARENT<span style="color: #66cc66;">.</span>UNIQUENAME
<span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#91;</span>Measures<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Label<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">,</span> 
        <span style="color: #66cc66;">&#91;</span>Measures<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>UniqueName<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">,</span> 
        <span style="color: #66cc66;">&#91;</span>Measures<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Ordinal<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">,</span>
        <span style="color: #66cc66;">&#91;</span>Measures<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Parent<span style="color: #66cc66;">&#93;</span>
        <span style="color: #66cc66;">&#125;</span> <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #993333; font-weight: bold;">COLUMNS</span> <span style="color: #66cc66;">,</span> 
      <span style="color: #66cc66;">&#91;</span>Employee<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Employees<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span>ALLMEMBERS <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #993333; font-weight: bold;">ROWS</span> 
<span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #66cc66;">&#91;</span>Adventure Works<span style="color: #66cc66;">&#93;</span></pre></td></tr></table></div>

<p><img src="http://www.purplefrogsystems.com/blog/wp-content/uploads/2012/11/MDXDimensionMembers4.png" alt="" title="MDXDimensionMembers4" width="607" height="290" class="aligncenter size-full wp-image-647" /></p>
<p>Now go forth and query those dimension members&#8230;<br />
FrogBlog-Out</p>
]]></content:encoded>
			<wfw:commentRss>http://www.purplefrogsystems.com/blog/2012/11/querying-dimension-members-in-mdx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rock Paper Scissors Lizard Spock</title>
		<link>http://www.purplefrogsystems.com/blog/2012/10/rock-paper-scissors-lizard-spock/</link>
		<comments>http://www.purplefrogsystems.com/blog/2012/10/rock-paper-scissors-lizard-spock/#comments</comments>
		<pubDate>Fri, 05 Oct 2012 09:09:04 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Spatial]]></category>

		<guid isPermaLink="false">http://www.purplefrogsystems.com/blog/?p=624</guid>
		<description><![CDATA[I want to share with you some genius level work by Phil Quinn (blog &#124; twitter), who is furthering the boundaries of SQL Server. &#160; Phil has taken the spatial drawing code from an earlier Frog-blog and used it to create a fully functional Rock Paper Scissors Lizard Spock game, just using the power of [...]]]></description>
				<content:encoded><![CDATA[<div id="attachment_625" class="wp-caption alignright" style="width: 200px"><a href="http://www.purplefrogsystems.com/blog/wp-content/uploads/2012/10/RockPaperScissorsLizardSpock2.jpg"><img class=" wp-image-625  " title="RockPaperScissorsLizardSpock" src="http://www.purplefrogsystems.com/blog/wp-content/uploads/2012/10/RockPaperScissorsLizardSpock2.jpg" alt="" width="190" height="165" /></a><p class="wp-caption-text">(Image courtesy of <a href="http://GraphJam.com">GraphJam.com</a>)</p></div>
<p>I want to share with you some genius level work by Phil Quinn (<a href="http://rqdb.wordpress.com/" target="_blank">blog </a>| <a href="http://twitter.com/SQLPippy" target="_blank">twitter</a>), who is furthering the boundaries of SQL Server.</p>
<p>&nbsp;</p>
<p>Phil has taken the spatial drawing code from an <a href="/blog/2011/05/sql-server-art-using-spatial-data/" target="_blank">earlier Frog-blog </a>and used it to create a fully functional Rock Paper Scissors Lizard Spock game, just using the power of SQL Server. Not even the brightest boffins at Microsoft could ever have imagined that SQL Server would be able to provide such an awesome service to the World.</p>
<p>&nbsp;</p>
<p>Check out <a href="http://rqdb.wordpress.com/2012/10/04/being-silly-with-spatial-data/" target="_blank">Phil&#8217;s post and download the query here</a></p>
<p>&nbsp;</p>
<p>If you want to hear Phil speak, he&#8217;s doing a talk for <a href="http://www.SQLMidlands.com" target="_blank">SQL Midlands</a> on 22nd November in Birmingham. His talk will be on using XML in SQL Server, but I&#8217;m hoping that we&#8217;ll also be treated to a bit of Rock Paper Scissors Lizard Spock action&#8230;</p>
<p>&nbsp;</p>
<p style="text-align: center;"><a href="http://www.purplefrogsystems.com/blog/wp-content/uploads/2012/10/RockPaperScissorsLizardSpock.png"><img class="aligncenter  wp-image-626" title="RockPaperScissorsLizardSpock" src="http://www.purplefrogsystems.com/blog/wp-content/uploads/2012/10/RockPaperScissorsLizardSpock.png" alt="" width="461" height="76" /></a></p>
<p>&nbsp;</p>
<p>Frog-Blog-Out</p>
]]></content:encoded>
			<wfw:commentRss>http://www.purplefrogsystems.com/blog/2012/10/rock-paper-scissors-lizard-spock/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Find first order date in MDX</title>
		<link>http://www.purplefrogsystems.com/blog/2012/09/find-first-order-date-in-mdx/</link>
		<comments>http://www.purplefrogsystems.com/blog/2012/09/find-first-order-date-in-mdx/#comments</comments>
		<pubDate>Mon, 03 Sep 2012 09:05:49 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Analysis Services]]></category>
		<category><![CDATA[Calculated Member]]></category>
		<category><![CDATA[MDX]]></category>
		<category><![CDATA[OLAP]]></category>
		<category><![CDATA[SSAS]]></category>

		<guid isPermaLink="false">http://www.purplefrogsystems.com/blog/?p=608</guid>
		<description><![CDATA[I had an interesting question the other day; &#8220;how do I find the date of the first order/activity for a given customer/employee/product etc in MDX&#8221;? Well you&#8217;ll be pleased to know that it&#8217;s pretty simple. The sample code bellow will work with the AdventureWorks DW 2008R2 cube. First of all we need to filter the [...]]]></description>
				<content:encoded><![CDATA[<p>I had an interesting question the other day; &#8220;how do I find the date of the first order/activity for a given customer/employee/product etc in MDX&#8221;?</p>
<p>Well you&#8217;ll be pleased to know that it&#8217;s pretty simple. The sample code bellow will work with the AdventureWorks DW 2008R2 cube.</p>
<p>First of all we need to filter the date dimension to contain only those with orders. Then take the first item of the resulting set, then find its name. Simples.</p>
<p>Filter the date hierarchy to only those dates with a Reseller Order Count:</p>
<pre class="code">   FILTER([Date].[Date].[Date].MEMBERS, [Measures].[Reseller Order count])</pre>
<p>Note that you can specify a more advanced filter, such as [Measures].[Reseller Order Count]&gt;10, which would find the first date which had more than 10 orders.</p>
<p>Then find the first item:</p>
<pre class="code">   .ITEM(0)</pre>
<p>Then find the its name:</p>
<pre class="code">   .NAME</pre>
<p>Put this together in a query and you get:</p>
<pre class="code">   WITH MEMBER [Measures].[First Activity] AS
       FILTER([Date].[Date].[Date].MEMBERS
            , [Measures].[Reseller Order count]).ITEM(0).NAME
   SELECT {[Measures].[Reseller Order count]
         , [Measures].[First Activity]
       } ON 0,
      [Employee].[Employees].MEMBERS ON 1
   FROM [Adventure Works]</pre>
<p>This returns the total reseller order count for each employee, along with the date of their first reseller order. Note that the Employee hierarchy here is a parent child hierarchy. The calculated member [First Activity] will aggregate and calculate correctly with any dimension or member specified on the 1 (ROWS) axis, be it a parent-child, single attribute, normal hierarchy, etc. and will always find the first order date for the current member.<br />
You should get the following results:</p>
<p><img class="aligncenter size-full wp-image-617" title="MDXFindFirstDate" src="http://www.purplefrogsystems.com/blog/wp-content/uploads/2012/09/MDXFindFirstDate1.png" alt="" width="401" height="386" /></p>
<p>Frog-Blog Out.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.purplefrogsystems.com/blog/2012/09/find-first-order-date-in-mdx/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Still time to register for SQL Saturday 162 in Cambridge</title>
		<link>http://www.purplefrogsystems.com/blog/2012/08/still-time-to-register-for-sql-saturday-162-in-cambridge/</link>
		<comments>http://www.purplefrogsystems.com/blog/2012/08/still-time-to-register-for-sql-saturday-162-in-cambridge/#comments</comments>
		<pubDate>Tue, 28 Aug 2012 09:10:59 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Community]]></category>

		<guid isPermaLink="false">http://www.purplefrogsystems.com/blog/?p=606</guid>
		<description><![CDATA[Just a quick reminder, if you haven&#8217;t registered already then get yourself to the SQL Saturday website and register for the UK&#8217;s first ever SQL Saturday, in Cambridge on Sept 8th 2012. The presenter/session line-up is awesome &#8211; check out the schedule here. I&#8217;ll be presenting a talk at 3:50pm on a better way to [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.sqlsaturday.com/viewsession.aspx?sat=162&amp;sessionid=9832mall.jpg"><img class="alignright size-full wp-image-603" title="SQLSat162Small" src="http://www.purplefrogsystems.com/blog/wp-content/uploads/2012/08/SQLSat162Small.jpg" alt="" width="200" height="53" /></a>Just a quick reminder, if you haven&#8217;t registered already then get yourself to the <a href="http://www.sqlsaturday.com/eventhome.aspx?eventid=244" target="_blank">SQL Saturday website</a> and register for the UK&#8217;s first ever SQL Saturday, in Cambridge on Sept 8th 2012.</p>
<p>The presenter/session line-up is awesome &#8211; check out the <a href="http://www.sqlsaturday.com/162/schedule.aspx" target="_blank">schedule here</a>. I&#8217;ll be presenting a talk at 3:50pm on a better way to load data warehouse dimensions.</p>
<p>I&#8217;m also proud to say that Purple Frog are sponsoring the event.</p>
<p>There aren&#8217;t many spaces left, so what are you waiting for?!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.purplefrogsystems.com/blog/2012/08/still-time-to-register-for-sql-saturday-162-in-cambridge/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Speaking at SQL Saturday 162 in Cambridge</title>
		<link>http://www.purplefrogsystems.com/blog/2012/08/speaking-at-sql-saturday-162-in-cambridge/</link>
		<comments>http://www.purplefrogsystems.com/blog/2012/08/speaking-at-sql-saturday-162-in-cambridge/#comments</comments>
		<pubDate>Wed, 01 Aug 2012 08:36:31 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[Event]]></category>
		<category><![CDATA[SQL Saturday]]></category>

		<guid isPermaLink="false">http://www.purplefrogsystems.com/blog/?p=598</guid>
		<description><![CDATA[I&#8217;m thrilled to have been selected to speak at the UK&#8217;s first SQL Saturday event &#8211; A big thank you to the organisers, I&#8217;ll already buzzing about it! SQL Saturday #162 is being held in the fabulous city of Cambridge, with two days of awesome content. Pre-Con Training Day: Friday 7th September 2012 Free SQL [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.sqlsaturday.com/162/eventhome.aspx"><img class="alignright size-full wp-image-599" title="SQL Sat 162" src="http://www.purplefrogsystems.com/blog/wp-content/uploads/2012/08/SQLSat162Med.jpg" alt="SQL Saturday 162" width="300" height="79" /></a>I&#8217;m thrilled to have been selected to speak at the UK&#8217;s first SQL Saturday event &#8211; A big thank you to the organisers, I&#8217;ll already buzzing about it!</p>
<p>SQL Saturday #162 is being held in the fabulous city of Cambridge, with two days of awesome content.</p>
<p>Pre-Con Training Day: Friday 7th September 2012</p>
<p>Free SQL Saturday: Saturday 8th September 2012</p>
<p>Full details on the <a href="http://www.sqlsaturday.com/162/eventhome.aspx" target="_blank">SQL Saturday website here</a>.</p>
<p>I&#8217;ll be reviving my talk discussing my MSc thesis, discussing the performance of loading data warehouse dimensions using SSIS, specifically how you can use the T-SQL Merge statement to automate and improve the speed of development and execution. Have a look through my recent blog posts for more information!</p>
<p>It&#8217;s going to be an awesome event, hope to see you there!!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.purplefrogsystems.com/blog/2012/08/speaking-at-sql-saturday-162-in-cambridge/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MSc Dissertation &#8211; Performance of Loading SCDs in SSIS</title>
		<link>http://www.purplefrogsystems.com/blog/2012/07/msc-dissertation-performance-of-loading-scds-in-ssis/</link>
		<comments>http://www.purplefrogsystems.com/blog/2012/07/msc-dissertation-performance-of-loading-scds-in-ssis/#comments</comments>
		<pubDate>Fri, 20 Jul 2012 13:57:09 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Business Intelligence]]></category>
		<category><![CDATA[Integration Services]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Merge]]></category>
		<category><![CDATA[MSc]]></category>
		<category><![CDATA[SCD]]></category>
		<category><![CDATA[SSIS]]></category>

		<guid isPermaLink="false">http://www.purplefrogsystems.com/blog/?p=583</guid>
		<description><![CDATA[Well after 3.5 years, I&#8217;ve finally completed my MSc Business Intelligence &#8211; hoorah! And to reward the time, effort and increased grey hair, they saw fit to give me a merit as well. During the last year I&#8217;ve been writing a thesis investigating the performance characteristics of loading data into data warehouse dimensions. Specifically loading [...]]]></description>
				<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-591" title="Frog-Cartoon-Graduate-LowRes" src="http://www.purplefrogsystems.com/blog/wp-content/uploads/2012/07/Frog-Cartoon-Graduate-LowRes.jpg" alt="" width="200" height="245" />Well after 3.5 years, I&#8217;ve finally completed my MSc Business Intelligence &#8211; hoorah! And to reward the time, effort and increased grey hair, they saw fit to give me a merit as well.</p>
<p>During the last year I&#8217;ve been writing a thesis investigating the performance characteristics of loading data into data warehouse dimensions. Specifically loading Type 2 SCDs using SSIS.</p>
<p>For those who have followed the previous posts and my conference talks on using T-SQL Merge for the purpose, you won&#8217;t be surprised at the direction of the dissertation, but it provides a useful performance comparison between T-SQL Merge, SSIS Merge Join, SSIS Lookup and the SSIS SCD Wizard.</p>
<p>I won&#8217;t go into the full details here of the project or results, but will show a couple of the summary charts which are of most interest. You can download the full project here:</p>
<ul>
<li><a onclick="pageTracker._trackPageview('/downloads/AlexWhittlesDissertation.pdf'); " href="/download/blog/AlexWhittlesDissertation.pdf" target="_self">PDF: <strong>Performance comparison of techniques to load Type 2 slowly changing dimensions in a Kimball style data warehouse using SSIS</strong></a></li>
</ul>
<p>The charts below shows the duration taken for the Lookup, Merge and Merge-Join methods (SCD Wizard excluded for obvious reasons!).<br />
The top chart shows the performance on a Raid 10 array of traditional hard disks.<br />
The second chart shows the same tests run on a Fusion IO NAND flash card.<br />
<img class="aligncenter size-full wp-image-586" title="Type 2 SCD Load Performance HDD" src="http://www.purplefrogsystems.com/blog/wp-content/uploads/2012/07/Type2LoadPerformanceHDD.jpg" alt="" width="662" height="374" /><br />
<img class="aligncenter size-full wp-image-587" title="Type 2 SCD Load Performance SSD" src="http://www.purplefrogsystems.com/blog/wp-content/uploads/2012/07/Type2LoadPerformanceSSD.jpg" alt="" width="662" height="374" /></p>
<p>The charts clearly show that the Lookup method is the least favoured. Of the other two, Merge is [just] preferred when using solid state, although statistically they are equivalent. On HDDs, Merge and Merge-Join are equivalent until you&#8217;re loading 2-3m rows per batch, at which point Merge-Join becomes the preferred option.</p>
<p>Full test results and analysis in the PDF download above.</p>
<p>My previous few posts show how using a T-SQL approach like Merge can provide huge development benefits by automating the code. This research now shows that unless you&#8217;re loading very large data volumes the performance is equivalent to more traditional approaches.</p>
<p>Hope this is of use. If you want to know a bit more without reading the full 99 pages &amp; 23k words (who could blame you?!), then my <a href="http://www.sqlbits.com/Sessions/Event10/Loading_Data_Warehouse_Dimensions_in_SSIS">SQLBits talk video is now on-line here</a>. This talk is slightly out of date as it was presented before I&#8217;d finished the research and analysis, but it&#8217;s largely accurate. I presented a more up to date version on a webinar for the PASS Virtual BI chapter. The recording isn&#8217;t currently available [When this post was written] but should be up soon. Keep checking on the <a href="http://bi.sqlpass.org/PresentationArchive.aspx">BI PASS Chapter website</a>.</p>
<p>Frog-Blog-Out</p>
]]></content:encoded>
			<wfw:commentRss>http://www.purplefrogsystems.com/blog/2012/07/msc-dissertation-performance-of-loading-scds-in-ssis/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
