<?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; Analysis Services</title>
	<atom:link href="http://blog.datainspirations.com/category/analysis-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>SQLU MDX Week: A Gentle Introduction to Sets</title>
		<link>http://blog.datainspirations.com/2011/12/16/sqlu-mdx-week-an-introduction-to-sets/</link>
		<comments>http://blog.datainspirations.com/2011/12/16/sqlu-mdx-week-an-introduction-to-sets/#comments</comments>
		<pubDate>Fri, 16 Dec 2011 12:51:15 +0000</pubDate>
		<dc:creator>Stacia Misner</dc:creator>
				<category><![CDATA[Analysis Services]]></category>
		<category><![CDATA[MDX]]></category>
		<category><![CDATA[SQL University]]></category>

		<guid isPermaLink="false">http://blog.datainspirations.com/?p=611</guid>
		<description><![CDATA[Welcome to my third post in a series of topics on MDX for SQL University. If you&#8217;re just now joining me, you should check out the first post, Location, Location, Location, and my previous post, Writing Simple Queries, to get oriented. I&#8217;m going to continue building on the concepts introduced in the earlier posts by showing [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://sqlchicken.com/sql-university" target="_blank"><img class="size-full wp-image-428 alignleft" title="SQL University" src="http://blog.datainspirations.com/wp-content/uploads/2011/05/SQL_University.png" alt="" width="175" height="200" /></a><br />
Welcome to my third post in a series of topics on MDX for <a href="http://sqlchicken.com/sql-university/" target="_blank">SQL University</a>. If you&#8217;re just now joining me, you should check out the first post, <a title="SQLU MDX Week: Location, Location, Location" href="http://blog.datainspirations.com/2011/12/13/sqlu-mdx-week-location-location-location/" target="_blank">Location, Location, Location</a>, and my previous post, <a title="SQLU MDX Week: Writing Simple Queries" href="http://blog.datainspirations.com/2011/12/14/sqlu-mdx-week-writing-simple-queries/" target="_blank">Writing Simple Queries</a>, to get oriented. I&#8217;m going to continue building on the concepts introduced in the earlier posts by showing you how to use functions to create a set to use on an axis.</p>
<p>Many times you&#8217;re interested in seeing values for all of the members of a particular attribute hierarchy. For example, in this query, we can see sales for all categories and for all years, including a grand total for categories and years and also years that have no sales.</p>
<pre>SELECT
[Date].[Calendar Year].Members
 ON COLUMNS,
[Product].[Category].Members ON ROWS
FROM [Adventure Works]
WHERE [Measures].[Sales Amount]</pre>
<p style="text-align: center;"><a href="http://blog.datainspirations.com/wp-content/uploads/2011/12/mdx-05.gif"><img class="aligncenter size-full wp-image-613" title="mdx-05" src="http://blog.datainspirations.com/wp-content/uploads/2011/12/mdx-05.gif" alt="" width="529" height="112" /></a></p>
<p>When you use the Members function with a dimension and hierarchy, you get everything listed in the Members folder:</p>
<p style="text-align: center;"><a href="http://blog.datainspirations.com/wp-content/uploads/2011/12/members.gif"><img class="aligncenter size-full wp-image-614" title="members" src="http://blog.datainspirations.com/wp-content/uploads/2011/12/members.gif" alt="" width="204" height="193" /></a></p>
<p>What if you don&#8217;t want the All Periods member to show up? Well, you could create a set like this {[Date].[Calendar].[CY 2005], [Date].[Calendar.[CY 2006], &#8230;} but that would be tedious, and it wouldn&#8217;t automatically include new members that get added to the dimension over time. Instead, you can use the Members function with the dimension, hierarchy, and level reference to skip over the All Periods like this:</p>
<pre>SELECT
[Date].[Calendar Year].[Calendar Year].Members
 ON COLUMNS,
[Product].[Category].Members ON ROWS
FROM [Adventure Works]
WHERE [Measures].[Sales Amount]</pre>
<p style="text-align: center;"><a href="http://blog.datainspirations.com/wp-content/uploads/2011/12/mdx-06.gif"><img class="aligncenter size-full wp-image-615" title="mdx-06" src="http://blog.datainspirations.com/wp-content/uploads/2011/12/mdx-06.gif" alt="" width="450" height="97" /></a></p>
<p>Here we have a case of &#8220;more is less.&#8221; When we use a level reference, such as we do with the expression [Date].[Calendar Year].[Calendar Year].Members, we are providing more specific instructions to the Members function so that we can get less data. Using a level reference works with both attribute hierarchies (the ones with two levels only) and user-defined hierarchies (the ones with multiple levels and a pyramid-shaped icon).</p>
<p style="text-align: center;"><a href="http://blog.datainspirations.com/wp-content/uploads/2011/12/level-members.gif"><img class="aligncenter size-full wp-image-616" title="level-members" src="http://blog.datainspirations.com/wp-content/uploads/2011/12/level-members.gif" alt="" width="198" height="230" /></a></p>
<p>One more little change to this query might make it better. If we don&#8217;t want to see CY 2009 and CY 2010 columns when they are empty, we add the NON EMPTY keyword in front of the set definition like this:</p>
<pre>SELECT
NON EMPTY [Date].[Calendar Year].[Calendar Year].Members
 ON COLUMNS,
[Product].[Category].Members ON ROWS
FROM [Adventure Works]
WHERE [Measures].[Sales Amount]</pre>
<p>What if we want to see the category sales broken down not only by year, but also by sales territory? We can combine sets on an axis using the CrossJoin function like this:</p>
<pre>SELECT
NON EMPTY [Date].[Calendar Year].[Calendar Year].Members
 ON COLUMNS,
NON EMPTY
CrossJoin([Product].[Category].Members,
	[Sales Territory].[Sales Territory Group].[Sales Territory Group].Members)
ON ROWS
FROM [Adventure Works]
WHERE [Measures].[Sales Amount]</pre>
<pre><a href="http://blog.datainspirations.com/wp-content/uploads/2011/12/mdx-07.gif"><img class="aligncenter size-full wp-image-619" title="mdx-07" src="http://blog.datainspirations.com/wp-content/uploads/2011/12/mdx-07.gif" alt="" width="423" height="248" /></a></pre>
<p>The CrossJoin function takes only two arguments, but you can use that expression as one argument in a second CrossJoin function to create a grouping of three dimension hierarchies on an axis. There are several ways to get the crossjoin effect which might be easier to read when you start adding more dimension hierarchies to the mix. One is the use of a &#8220;polymorphic operator&#8221; such as an asterisk * like this:</p>
<pre>[Product].[Category].Members *
[Sales Territory].[Sales Territory Group].[Sales Territory Group].Members</pre>
<p>The other is to create a tuple set like this:</p>
<pre>([Product].[Category].Members,
[Sales Territory].[Sales Territory Group].[Sales Territory Group].Members)</pre>
<p>I know I said in a previous post that a tuple is like a coordinate to a cell, and it appears in the above example that I&#8217;m violating that rule by using sets in a tuple. But Analysis Services resolves this expression as a set of tuples by taking every member of the first set (the product category members) to create a tuple with every member of the second set (sales territory group members).  That set gets placed on the rows axis and the set of calendar year members gets placed on the columns axis, and then the tuple coordinates for each intersection of a row and a column produces a new tuple definition that generates a result, such as $709,947.20 for the pseudo-tuple (All Products, Europe, CY 2005).</p>
<p>There are many more functions that we can use to generate sets to control what we see on rows or columns. More than I can cover in this post. (In fact, there are entire books that cover this topic. In a future post, I&#8217;ll provide some recommendations.) For now, I&#8217;ll leave you with one more function to add to your repertoire. This time we want to see only those product categories and sales territory combinations that have sales greater than $1 million in CY 2008, but we want to see their sales for all years. To do this, we use the Filter function. This should satiate your desire to use a WHERE clause in your query, which I told you in my previous post does not work like a filter as it does in a T-SQL query.</p>
<pre>SELECT
NON EMPTY [Date].[Calendar Year].[Calendar Year].Members
 ON COLUMNS,
Filter(
	([Product].[Category].[Category].Members,
		[Sales Territory].[Sales Territory Group].[Sales Territory Group].Members),
	([Measures].[Sales Amount],[Date].[Calendar Year].&amp;[2008])  &gt; 1000000)
ON ROWS
FROM [Adventure Works]
WHERE [Measures].[Sales Amount]</pre>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2011/12/mdx-08.gif"><img class="aligncenter size-full wp-image-620" title="mdx-08" src="http://blog.datainspirations.com/wp-content/uploads/2011/12/mdx-08.gif" alt="" width="520" height="98" /></a></p>
<p>The Filter function takes two arguments. The first is the set that you want to filter. And the second is a Boolean expression that determines which members will be in the set that the Filter function produces. In this case, I used a tuple expression to focus on the 2008 sales.  If I had used only Sales Amount, the filter would have produced a set of category/territory combinations having total sales for all years greater than $1 million.</p>
<p>The key concept to take away from this post is that sets go on rows and columns, and that we can control very precisely which members are in those sets by using functions and tuple sets. A very common function to use is the Members function, and it&#8217;s also common to use NON EMPTY to rid ourselves of rows or columns that contain only null values.</p>
<pre></pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.datainspirations.com/2011/12/16/sqlu-mdx-week-an-introduction-to-sets/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>SQLU MDX Week: Writing Simple Queries</title>
		<link>http://blog.datainspirations.com/2011/12/14/sqlu-mdx-week-writing-simple-queries/</link>
		<comments>http://blog.datainspirations.com/2011/12/14/sqlu-mdx-week-writing-simple-queries/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 16:57:55 +0000</pubDate>
		<dc:creator>Stacia Misner</dc:creator>
				<category><![CDATA[Analysis Services]]></category>
		<category><![CDATA[MDX]]></category>
		<category><![CDATA[SQL University]]></category>

		<guid isPermaLink="false">http://blog.datainspirations.com/?p=601</guid>
		<description><![CDATA[This post is the second in a series of topics on MDX for SQL University. In my first post, Location, Location, Location, I introduced the tuple as a way to retrieve data from a cube with very precise instructions about what you want. In this post, I&#8217;m going to show you how to do that by [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://sqlchicken.com/sql-university" target="_blank"><img class="size-full wp-image-428 alignleft" title="SQL University" src="http://blog.datainspirations.com/wp-content/uploads/2011/05/SQL_University.png" alt="" width="175" height="200" /></a><br />
This post is the second in a series of topics on MDX for <a href="http://sqlchicken.com/sql-university/" target="_blank">SQL University</a>. In my first post, <a title="SQLU MDX Week: Location, Location, Location" href="http://blog.datainspirations.com/2011/12/13/sqlu-mdx-week-location-location-location/" target="_blank">Location, Location, Location</a>, I introduced the tuple as a way to retrieve data from a cube with very precise instructions about what you want. In this post, I&#8217;m going to show you how to do that by writing queries. One thing that you will have to promise me as you read this post is to forget what you know about SQL queries (presuming you have some knowledge in that area). It will mess you up. If you start with a clean slate, you will have an easier time of it.</p>
<h3>Preparing the Query Environment</h3>
<p>Before I dive into writing queries, let me explain the setup. I&#8217;m using SQL Server 2008 R2 Analysis Services for these examples. You can work with earlier versions, but in some cases you will encounter date ranges that are four years earlier than the date shown in my examples. For example, instead of using Q3 2007, you would need to use Q3 2004. The measure values will remain the same. Here are links to the samples that you need to have installed:</p>
<ul>
<li style="text-align: left;">If using Microsoft SQL Server 2005, install the sample databases (AdventureWorks, AdventureWorksDW)</li>
<li style="text-align: left;">If using a later version, download the sample databases from <a href="http://msftdbprodsamples.codeplex.com/">http://msftdbprodsamples.codeplex.com/</a>, install the databases, and then follow the instructions at <a href="http://msftdbprodsamples.codeplex.com/wikipage?title=Installing%20Analysis%20Services%20Database">http://msftdbprodsamples.codeplex.com/wikipage?title=Installing%20Analysis%20Services%20Database</a> to install and deploy the Analysis Services database.</li>
</ul>
<h3>Requesting a Tuple from a Cube</h3>
<p>Okay, let&#8217;s start simple. Very, very simple. Go to SQL Server Management Studio, connect to Analysis Services, and click the MDX button on the query toolbar. An MDX query editor window will open. In the Available Databases drop-down list, select the Adventure Works database for your version of SSAS.</p>
<p>To retrieve a tuple from the cube named Adventure Works, you write a query like this:</p>
<pre>SELECT FROM [Adventure Works] 
WHERE
([Product].[Product].&amp;[359],[Date].[Date].[January 1, 2008],[Measures].[Sales Amount])</pre>
<p><span class="Apple-style-span" >Notice the way that I refer to dimension members here. I&#8217;m no longer writing a pseudo-tuple as I did in my previous post, but am now using member unique names which tells Analysis Services the dimension and  hierarchy to which the member belongs. If you leave out the dimension and hierarchy, you will still get an answer, but no guarantee that you have the right answer if it&#8217;s possible that another dimension and hierarchy contain a member of the same name. For example, what if I have a West region and a sales person with the last name of West? Analysis Services will use one or the other to construct the tuple. The only way I can control which one is to use the dimension and hierarchy name. In fact, I switched from using Mountain-200 Black, 38 to [Product].[Product].&amp;[359] because there are two products with the name Mountain-200 Black, 38 (due to Slowly Changing Dimensions) and I want the one that actually has sales for January 1, 2008. I can refer to members not only by name, but by the value in the key column &#8211; which in this case is the surrogate key for the dimension. I use an ampersand before the key value wrapped in brackets to specify that it&#8217;s a key column in the tuple rather than a member name .</span></p>
<p>Now let&#8217;s see the results of the query. Press F5 or the Execute button in the toolbar to see a single value appear in the Results pane.</p>
<p><strong><a href="http://blog.datainspirations.com/wp-content/uploads/2011/12/mdx-01.gif"><img class="aligncenter size-full wp-image-603" title="mdx-01" src="http://blog.datainspirations.com/wp-content/uploads/2011/12/mdx-01.gif" alt="" width="154" height="52" /></a><br />
</strong></p>
<p>The WHERE clause in your query contains the tuple that you want to retrieve. It does NOT behave like a WHERE clause in a SQL query, which is why I asked you nicely to forget about that other language &#8211; at least for the duration of this post. The problem with requesting a tuple this way is that the result does not include any metadata that tells me what I&#8217;m looking at. So I can enhance this query by showing one of the members of the tuple as a column label and one of the other members of the tuple as a row label, like this:</p>
<pre>SELECT 
[Date].[Date].[January 1, 2008] ON COLUMNS,
[Product].[Product].&amp;[359] ON ROWS
FROM [Adventure Works] 
WHERE [Measures].[Sales Amount]</pre>
<p>Press F5 to see that the result of the query is the same, but now we have some more context for the value that displays.</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2011/12/mdx-02.gif"><img class="aligncenter size-full wp-image-604" title="mdx-02" src="http://blog.datainspirations.com/wp-content/uploads/2011/12/mdx-02.gif" alt="" width="232" height="68" /></a></p>
<p>The way that I like to think about the query results for this example is that it works in three phases. First, Analysis Services retrieves my request for the member on columns. Second, it retrieves my request for the member on rows. Those two steps occur completely independently of one another. Third, Analysis Services looks at the intersections produced by placing member on columns and rows and adds in the WHERE clause to produce a tuple. That&#8217;s why we get the same value in the result. It doesn&#8217;t matter which member you put on columns and which member you put on rows and which you leave in the WHERE clause. Collectively, they produce a tuple.</p>
<p>You don&#8217;t have to use a WHERE clause in the query. Instead, you could put everything onto an axis &#8211; either rows or columns. Essentially, you&#8217;re moving the tuple fragments out of the WHERE clause onto an axis. The tuple produced by the query parser is the same, but we get more metadata in the results to see the context of the query. For example, try this:</p>
<pre>SELECT 
([Date].[Date].[January 1, 2008], [Measures].[Sales Amount]) ON COLUMNS,
[Product].[Product].&amp;[359] ON ROWS
FROM [Adventure Works]</pre>
<p>Here you see the results of the new query.</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2011/12/mdx-03.gif"><img class="aligncenter size-full wp-image-605" title="mdx-03" src="http://blog.datainspirations.com/wp-content/uploads/2011/12/mdx-03.gif" alt="" width="229" height="87" /></a></p>
<p>You can put any member of the tuple on either rows or columns. You can even write the query to show rows first and columns second like this:</p>
<pre>SELECT 
[Product].[Product].&amp;[359] ON COLUMNS,
([Date].[Date].[January 1, 2008], [Measures].[Sales Amount]) on ROWS
FROM [Adventure Works]</pre>
<p>But the result of your query stays the same. You can have a query that only has a tuple fragment on columns like this:</p>
<pre>SELECT 
([Date].[Date].[January 1, 2008], [Measures].[Sales Amount]) ON COLUMNS
FROM [Adventure Works]</pre>
<p>But you cannot have a query that has a tuple fragment on rows like this:</p>
<pre>SELECT 
([Date].[Date].[January 1, 2008], [Measures].[Sales Amount]) ON ROWS
FROM [Adventure Works]</pre>
<p>If I don&#8217;t ask for something in a tuple explicitly by putting it on columns, on rows, or in the WHERE clause, Analysis Services plugs in the All member for the dimension and hierarchy that I didn&#8217;t include. Usually. There is an exception but we&#8217;ll save that explanation for another post. This behavior is especially helpful when you have lots of dimensions and hierarchies. Otherwise, you&#8217;d have a tuple that is  ginormous (your new technical term for the day).</p>
<h3>Using Sets in a Query</h3>
<p>Asking for data one tuple at a time is rather tedious. Fortunately, we can take our knowledge about query construction to the next level. Technically speaking, when we put a member on columns or rows, we were asking for a set. A set of one. When we put the tuple fragment on columns or rows, we were creating a tuple set. Another option is to explicitly create a set like this:</p>
<pre>SELECT
{[Date].[Date].[January 1, 2008], [Date].[Date].[February 1, 2008]} ON COLUMNS,
[Product].[Product].&amp;[359] ON ROWS
FROM [Adventure Works]
WHERE [Measures].[Sales Amount]</pre>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2011/12/mdx-04.gif"><img class="aligncenter size-full wp-image-607" title="mdx-04" src="http://blog.datainspirations.com/wp-content/uploads/2011/12/mdx-04.gif" alt="" width="305" height="43" /></a></p>
<p>Whereas we use parentheses to denote a tuple, we use braces to denote a set. The order in which we define the member of the set determines the order in which the members display in the results. Try changing the sequence of members in the set to see the results.</p>
<p>MDX provides us with lots of functions to produce sets or to produce members that we use in sets so that we don&#8217;t have to list out members explicitly in a query. In my next post, we&#8217;ll explore some some of these functions.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.datainspirations.com/2011/12/14/sqlu-mdx-week-writing-simple-queries/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SQLU MDX Week: Location, Location, Location</title>
		<link>http://blog.datainspirations.com/2011/12/13/sqlu-mdx-week-location-location-location/</link>
		<comments>http://blog.datainspirations.com/2011/12/13/sqlu-mdx-week-location-location-location/#comments</comments>
		<pubDate>Tue, 13 Dec 2011 19:20:01 +0000</pubDate>
		<dc:creator>Stacia Misner</dc:creator>
				<category><![CDATA[Analysis Services]]></category>

		<guid isPermaLink="false">http://blog.datainspirations.com/?p=588</guid>
		<description><![CDATA[Once again, I am serving as the professor at SQL University during MDX week. MDX stands for MultiDimension eXpression language and we use it to add business logic to cubes in the form of calculations, named sets, and KPIs as well as to configure security and to write reports. I can’t teach you everything you need [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://sqlchicken.com/sql-university" target="_blank"><img class="size-full wp-image-428 alignleft" title="SQL University" src="http://blog.datainspirations.com/wp-content/uploads/2011/05/SQL_University.png" alt="" width="175" height="200" /></a><br />
Once again, I am serving as the professor at <a href="http://sqlchicken.com/sql-university/" target="_blank">SQL University</a> during MDX week. MDX stands for MultiDimension eXpression language and we use it to add business logic to cubes in the form of calculations, named sets, and KPIs as well as to configure security and to write reports. I can’t teach you everything you need to know about MDX in just a few blog posts this week, but I can help you get into the right frame of mind to learn MDX, to get some insight into how the language works, and where to learn more to further your studies.</p>
<p>Before you undertake MDX, you should know something about Analysis Services and cubes. Earlier this year, I presented a series of posts as part of SQL  University to introduce you to this topic:</p>
<ul>
<li><a href="http://blog.datainspirations.com/2011/05/11/sqlu-ssas-week-why-do-i-need-a-cube-how-do-i-get-started/" target="_blank">Why Do I Need a Cube and How Do I Get Started?</a></li>
<li><a href="http://blog.datainspirations.com/2011/05/11/sqlu-ssas-week-dimension-design-101-2/" target="_blank">Dimension Design 101</a></li>
<li><a href="http://blog.datainspirations.com/2011/05/12/sqlu-ssas-week-cube-construction-101/" target="_blank">Cube Construction 101</a></li>
<li><a href="http://blog.datainspirations.com/2011/05/15/sqlu-ssas-week-cube-enhancements-101/" target="_blank">Cube Enhancements 101</a></li>
<li><a href="http://blog.datainspirations.com/2011/05/17/sqlu-ssas-week-cube-deployment-101/" target="_blank">Cube Deployment 101</a></li>
</ul>
<p>Before we dive into using MDX later this week, let’s start with perhaps the most fundamental concept that you need to understand – location, location, location.</p>
<h3><strong>Build On What You Know</strong></h3>
<p>You’ve probably used an Excel spreadsheet at some point and are familiar with using cell references to create formulas. For example, in the spreadsheet below, if I want to perform a calculation that includes the sales for the product “Mountain-200 Black, 38” on 1/1/2008, I would use the formula =B2. The letter B stands for the column reference and the number 2 stands for the row reference. It’s a two-dimensional cell reference.</p>
<p style="text-align: center;"><a href="http://blog.datainspirations.com/wp-content/uploads/2011/12/excel-01.png"><img class="aligncenter size-large wp-image-589" title="excel-01" src="http://blog.datainspirations.com/wp-content/uploads/2011/12/excel-01-1024x251.png" alt="" width="540" height="133" /></a></p>
<p>“OK,” you’re thinking. “I got that. Rudimentary Excel. What does that have to do with MDX?” Bear with me a little bit longer and I’ll connect the dots for you.</p>
<p>Now consider that I have two sheets in a workbook with a similar layout. One sheet for 2008 sales and one sheet for 2007 sales. I want to calculate total sales for the same product in January. In this case, I can use the formula =’Sales 2008’!B2 + ‘Sales 2007’!B2. I’ve added a third dimension, the sheet name, to the cell references to tell Excel where to find the data for the calculation.</p>
<p style="text-align: center;"><a href="http://blog.datainspirations.com/wp-content/uploads/2011/12/excel-02.png"><img class="aligncenter size-large wp-image-590" title="excel-02" src="http://blog.datainspirations.com/wp-content/uploads/2011/12/excel-02-1024x407.png" alt="" width="675" height="268" /></a></p>
<p>Let’s continue expanding on this concept:</p>
<ul>
<li>For four dimensions, let’s assume that I have a separate workbook for different stores and I want to combine the sales for all stores for the same product and same month across the two years. My formula would now look like this – ‘[Store A.xlsx]Sales 2008’!B2 + ‘[Store B.xlsx]Sales 2008’!B2 + ‘[Store A.xlsx]Sales 2007’!B2 + ‘[Store B.xlsx]Sales 2007’!B2.</li>
<li>For five dimensions, I might use different folders on the same drive to store workbooks by promotion. So now each workbook reference would look something like this: ‘[C:\Top Customer Promotion\Store A.xlsx]Sales 2008’!B2.</li>
<li>Moving on to six dimensions, I can reference workbooks on different drives.</li>
<li>For seven dimensions, I can reference workbooks on different servers.</li>
</ul>
<p>Now I’m going to get a bit silly, but just use your imagination with me for a moment because I can’t really do this. It’s just expanding the concept of location. Here goes… I can reference workbooks on different servers on different floors (eight dimensions), in different buildings (nine dimensions), on different streets (ten dimensions), in different cities (eleven dimensions), in different states (twelve dimensions), in different countries (thirteen dimensions), on different planets (fourteen dimensions) in different universes (fifteen dimensions)!</p>
<p>Okay, I’ve probably gone a bit too far with this example, and technically speaking, I wouldn’t make each of these aspects of a location into a separate dimension from an Analysis Services point of view. But I want you to get the idea that I can use location references in my Excel formulas to be very precise about which data to include in the formula. Excel understands relative references and absolute references. If you don’t tell it otherwise, it’s going to assume that you want a relative reference. That is, use the current cell, column, sheet,  or whatever that happens to be “current” for the cell in which you are typing the formula unless you give it explicit instructions to use a different cell, columns, sheet, or whatever.</p>
<h3>And Now for the Tuple</h3>
<p>Now let’s bring this back to MDX. A key concept in MDX is the tuple. I say tuh-ple because I learned it that way and I’m too old to change. (Think quintuple, sextuple, octuple – et cetera. The letter u is short the way that I learned.) Some people say too-ple, and that’s okay too. The beauty of reading a blog post is that you can read it with whichever pronunciation you prefer and my pronunciation won’t get in your way!</p>
<p>Let’s move our sales data from Excel into an Analysis Services cube. I’ve simplified the product name because the tire size in there seems to distract people. So “Mountain-200 Black, 38” becomes “Mountain-200 Black.”</p>
<p style="text-align: center;"><a href="http://blog.datainspirations.com/wp-content/uploads/2011/12/tuple-01.png"><img class="aligncenter size-full wp-image-591" title="tuple-01" src="http://blog.datainspirations.com/wp-content/uploads/2011/12/tuple-01.png" alt="" width="499" height="326" /></a></p>
<p>To get data from a cube, I need to ask for that data in the form of a tuple. A tuple consists of one member from every dimension. So in my two dimensional representation of cube data above, the tuple to get sales for the Mountain-200 Black product in January would be (Mountain-200 Black, 1/1/2008).</p>
<p>Actually, that’s what I call a pseudo-tuple because it’s not exactly the way we would write it in MDX, but I don’t want you to get distracted by the details. For now, let’s focus on the concepts of a tuple.</p>
<p>Tuples are like coordinates that you learned in geometry. If you have a graph with two dimensions, x and y, you represent a point by using the coordinate (x,y). In geometry, order matters – the x must come before the y. But with tuples, order does NOT matter. We can write your example above as either (Mountain-200 Black, 1/1/2008) or (1/1/2008, Mountain-200 Black) and get the same answer: $66,095.71.</p>
<p>Now in our cube, most dimensions have an All level. And that counts as a cell, too. So we can create a tuple (All Products, All Dates) to get the grand total sales: $4,831,250.71.</p>
<p style="text-align: center;"><a href="http://blog.datainspirations.com/wp-content/uploads/2011/12/tuple-02.png"><img class="aligncenter size-full wp-image-592" title="tuple-02" src="http://blog.datainspirations.com/wp-content/uploads/2011/12/tuple-02.png" alt="" width="527" height="337" /></a></p>
<p>If we have two kinds of measures in our sales, Sales Amount and Order Quantity, then that adds a third dimension to our cube. So our tuple changes accordingly to include the new dimension: (Mountain-200 Black, 1/1/2008, Sales Amount).</p>
<p style="text-align: center;"><a href="http://blog.datainspirations.com/wp-content/uploads/2011/12/tuple-03.png"><img class="aligncenter size-large wp-image-593" title="tuple-03" src="http://blog.datainspirations.com/wp-content/uploads/2011/12/tuple-03-1024x569.png" alt="" width="614" height="341" /></a></p>
<p>In summary, a tuple is just a location in a cube. We use it to tell Analysis Services where to find the data that we want. Using MDX functions, we can describe sets of tuples that we want to access “as is” or use in formulas. In my next post, I’ll explain how to write simple MDX queries using this concept of tuples.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.datainspirations.com/2011/12/13/sqlu-mdx-week-location-location-location/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Book Review: MDX with Microsoft SQL Server 2008 R2 Analysis Services Cookbook</title>
		<link>http://blog.datainspirations.com/2011/10/21/book-review-mdx-with-microsoft-sql-server-2008-r2-analysis-services-cookbook/</link>
		<comments>http://blog.datainspirations.com/2011/10/21/book-review-mdx-with-microsoft-sql-server-2008-r2-analysis-services-cookbook/#comments</comments>
		<pubDate>Fri, 21 Oct 2011 19:39:49 +0000</pubDate>
		<dc:creator>Stacia Misner</dc:creator>
				<category><![CDATA[Analysis Services]]></category>
		<category><![CDATA[Book Review]]></category>
		<category><![CDATA[MDX]]></category>

		<guid isPermaLink="false">http://blog.datainspirations.com/2011/10/21/book-review-mdx-with-microsoft-sql-server-2008-r2-analysis-services-cookbook/</guid>
		<description><![CDATA[As I mentioned in an earlier post, I first met Tomislav Piasevoli’s (blog&#124;twitter) in 2008 at the PASS Summit in Seattle, and saw him again most recently again in Seattle at PASS Summit 2011. There I had the pleasure of telling him personally how much I liked his book. There are not many MDX books [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.packtpub.com/mdx-with-microsoft-sql-server-2008-r2-analysis-services/book"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; float: left; padding-top: 0px; border: 0px;" title="1308EN_MDX with Microsoft SQL Server Analysis Services 2008 R2 Cookbook" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/Book-Review-MDX-with-Microsoft-SQL-Serve_857B/1308EN_MDX-with-Microsoft-SQL-Server-Analysis-Services-2008-R2-Cookbook_thumb.png" border="0" alt="1308EN_MDX with Microsoft SQL Server Analysis Services 2008 R2 Cookbook" width="125" height="152" align="left" /></a></p>
<p>As I mentioned in <a href="http://blog.datainspirations.com/2011/09/09/back-to-the-future-with-mdx-and-pass/" target="_blank">an earlier post</a>, I first met Tomislav Piasevoli’s (<a href="http://tomislav.piasevoli.com/" target="_blank">blog</a>|<a href="http://twitter.com/tpiasevoli" target="_blank">twitter</a>) in 2008 at the PASS Summit in Seattle, and saw him again most recently again in Seattle at <a href="http://www.sqlpass.org/summit/2011/" target="_blank">PASS Summit 2011</a>. There I had the pleasure of telling him personally how much I liked his book. There are not many MDX books available, so when a new one arrives on the market, I definitely want to take a look. Now I have taught MDX classes for many years, and I think perhaps my first class was in 2002. However, it’s been so long now, I don’t recall exactly when that first class was. What I do know is that my understanding of MDX and my fluency with the language has grown by leaps and bounds since then through experience with all kinds of bleeding edge MDX, and I have tried to communicate some of my insights developed along the way to students in my classroom. MDX concepts can stretch your thinking (to put it mildly), and more so if you have to unlearn SQL concepts as well, which is true of the majority of my students. As a native English speaker, I can find it challenging at times to explain certain aspects of MDX. For all these reasons, I can fully appreciate Tomislav’s efforts to create this book and commend him for his excellent examples and explanations using a language that is not his mother tongue.</p>
<p>Tomislav’s book is definitely not for beginners. There is an underlying assumption that you already have some familiarity with the basics of MDX. The purpose of this book is to provide you with the tools necessary to continue building your skills. The chapters group together a series of related concepts, called recipes. You don’t need to read the book sequentially from cover to cover. Instead, you search for the desired outcome, such as handling division by zero errors (described in Chapter 1) or calculating row numbers (found in Chapter 7). Ideally, you don’t just read the recipe, but actually try out the steps yourself. I did some of my reading of this book when I was away from my laptop, and frequently found that I wanted to try out something that Tomislav mentioned. Even long-time MDX developers like myself can find interesting tidbits of information to round out their repertoire!</p>
<p>Each concept within a chapter is presented in a similar manner, beginning with “Getting ready” which are the steps you need to perform to set up your query. For example, you might need to work in Management Studio and set up a query as a starting point or open the Script View for a cube in Business Intelligence Development Studio. Then the next section is “How to do it…” which provides step-by-step instructions for working with a query or MDX script to accomplish the intended outcome. Then Tomislav continues with the “How it works…” section which provides background information on the key concepts for the current recipe. This section is the real meat of the book, but is nicely separated from the implementation steps if you want to jump straight to the technical details. Depending on the recipe, Tomislav also includes additional sections, such as “There’s more…” to provide alternative solutions or to point you to helpful links on the Internet such as whitepapers and blog articles providing more insight, and “See also…” to cross-reference you to another recipe in the book that covers a closely related concept.  Where applicable, he also includes information about how the techniques in the recipe behave differently in earlier versions of Analysis Services.</p>
<h5>Chapter 1: Elementary MDX Techniques</h5>
<p>Don’t let the word Elementary fool you into thinking you can learn entry-level MDX from this chapter. As I mentioned earlier, this book is not for beginners. There are good techniques here and a few basics, such as a great explanation of the FORMAT_STRING property and troubleshooting its use. However, I would consider the majority of these techniques to be elementary only as compared to the other techniques found later in the book. For example, the WHERE clause is one of those things that I see people really get into a tangle over (because they can’t forget their T-SQL), and Tomislav demonstrates using it to implement a logical OR on members from different hierarchies and a logical AND for members from the same hierarchy. One of my favorite sections in this chapter is the coverage of alternatives for the FILTER() function, which can cause performance problems. Use this chapter to get grounded with some foundational concepts, then strap on your seatbelt before diving into the rest of the book!</p>
<h5>Chapter 2: Working with Time</h5>
<p>Time is something that every cube has. Or at least every cube that I’ve ever met. I can’t imagine a cube without one (even if it’s called Date) because often business analysis is comparing one period to another or monitoring trends over time. Tomislav starts with the basics of the YTD() function but delves into variations on the theme and points out pitfalls to avoid. He moves on to parallel periods, moving averages, and finding last dates with data, among other time-related topics. A useful recipe in this chapter is the use of string functions to calculate a date, as I see this requirement a lot when working with Reporting Services reports that use Analysis Services as a source. A good case for working with a single-member named set rather than a calculated member is also made in this chapter.</p>
<h5>Chapter 3: Concise Reporting</h5>
<p>A report in this chapter means a pivot table used in some front-end tool for Analysis Services, and not Reporting Services exclusively. The goal of this chapter is to reduce the size of the pivot table, and thereby improve performance. I would characterize this chapter as one that helps you find the best or the worst members in a group, whether in a hierarchy, among siblings, or among descendants. Tomislav starts off the chapter with a recipe to get the top N members. In this recipe, Tomislav includes a great explanation of what can go wrong when you use the TopCount() function. Well, it’s not a matter of it behaving incorrectly because it’s doing what you ask. The problem is that many people misunderstand how the TopCount() function behaves under certain conditions and Tomislav delves deeply into the behavior here. He then builds on these ideas throughout the chapter and introduces alternatives for finding and displaying the best and the worst.</p>
<h5>Chapter 4: Navigation</h5>
<p>Hierarchies in a dimension are extremely useful for a number of reasons, one of which is navigation. The chapter begins with some simple queries that use Boolean logic to test the context of a current member on the row axis, and then expands to use scoping in the MDX script or use a query (using CELL CALCULATION) to determine if members are in the same branch of a hierarchy. Are you confused about when to use the Exists() function and the EXISTING keyword? Tomislav covers them both in this chapter in a variety of contexts. Also, having advocated on behalf of a named set in a previous chapter, Tomislav explores the pros and cons of named sets more fully in this chapter.</p>
<h5>Chapter 5: Business Analytics</h5>
<p>This chapter covers several techniques that are encountered less frequently (depending on who you ask, I suppose) than those covered up to this point in the book. For example, the chapter begins with linear regression which I’ve never had to use in 10 years of writing MDX. But I said the same about the Correlation() function once upon a time and I now use it frequently in a current project, so my feeling is that you never know when you’ll need to use a seemingly obscure function. Because these analytical functions are used less commonly, the amount of information available through Books Online or elsewhere on the Internet is pretty slim. Therefore, having this chapter’s working examples at your fingertips is invaluable. Also covered in this chapter is adjusting forecasts based on periodic cycles, alternative approaches to expense allocations, finding slow-moving inventory items, categorizing customers, and ABC analysis (which is an application of Pareto analysis).</p>
<h5>Chapter 6: When MDX is Not Enough</h5>
<p>In this chapter, Tomislav makes the case that when an MDX approach gets overly complicated, it’s time to look at making changes to the dimension or cube design. For example, he says, “Every time you catch yourself using functions like Except(), Filter(), or similar() too often in your calculations, you should step back and consider whether that’s a repeating behavior and whether it would pay off to have an attribute to separate the data you’ve been separating using MDX calculations.” He also explains how and why to create a placeholder measure in the cube to use with assignments in the MDX script. Utility dimensions for unit conversion or for time-based calculations are also covered in this chapter.</p>
<h5>Chapter 7: Context-aware Calculations</h5>
<p>Understanding context is an important aspect of MDX development. As Tomislav explains in the introduction to this chapter, context can be unpredictable based on what a user might select to place on rows and columns, or it can be partially known when you expect a particular measure or hierarchy to be used, or it can be completely known. The trick is to produce a calculation that behaves correctly regardless of context, which can be made trickier based on a combination of factors that Tomislav describes. The recipes in this chapter help you explore context from a number of, um, contexts, starting with how to know how many columns and rows will be in a query’s result set, how to determine which axis contains measures, how to determine what has been placed on an axis, among other useful techniques.</p>
<h5>Chapter 8: Advanced MDX Topics</h5>
<p>Now frankly I considered several of the recipes up to this point to be advanced, so I had to chuckle at the title of this chapter. Let’s just say these recipes are more complex! In this chapter, you’ll find techniques for working with parent-child hierarchies and displaying random values for sampling purposes. Hopefully, you’re avoiding the use of parent-child hierarchies and random sampling is not a common request in reports, so this section of the chapter is interesting primarily from an academic viewpoint. But then we move to complex sorts – a very useful subject indeed. Tomislav provides several examples and highlights potential problem areas. Also in this chapter is a recipe for recursively calculating cumulative values.</p>
<h5>Chapter 9: On the Edge</h5>
<p>Tomislav uses this chapter to collect topics that don’t neatly fit into the earlier chapters. Here he covers Analysis Services stored procedures (which are nothing like T-SQL stored procedures, by the way), as well as using the OPENQUERY() and OPENROWSET() functions for calling MDX from a T-SQL statement. He also introduces Dynamic Management Views (DMVs) for documenting and monitoring cubes, and shows how to use SQL Server Profiler to capture MDX queries. Last, he shows how to use the DRILLTHROUGH command.</p>
<p>If you’re an MDX developer, whether brand new or experienced, you will find lots of good information in this book and practical examples of how and why to implement specific techniques. I definitely recommend that you add it to your library, in whatever format you prefer. It’s available in <a href="http://www.packtpub.com/mdx-with-microsoft-sql-server-2008-r2-analysis-services/book" target="_blank">paperback, PDF, ePub and Mobi from the publisher</a> and in <a href="http://www.amazon.com/Microsoft-Analysis-Services-Cookbook-ebook/dp/B005HIK89S/ref=sr_1_2?ie=UTF8&amp;qid=1319215803&amp;sr=8-2" target="_blank">Kindle format from Amazon</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.datainspirations.com/2011/10/21/book-review-mdx-with-microsoft-sql-server-2008-r2-analysis-services-cookbook/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Back to the Future with MDX and PASS</title>
		<link>http://blog.datainspirations.com/2011/09/09/back-to-the-future-with-mdx-and-pass/</link>
		<comments>http://blog.datainspirations.com/2011/09/09/back-to-the-future-with-mdx-and-pass/#comments</comments>
		<pubDate>Fri, 09 Sep 2011 19:35:44 +0000</pubDate>
		<dc:creator>Stacia Misner</dc:creator>
				<category><![CDATA[Analysis Services]]></category>
		<category><![CDATA[MDX]]></category>
		<category><![CDATA[PASS]]></category>

		<guid isPermaLink="false">http://blog.datainspirations.com/2011/09/09/back-to-the-future-with-mdx-and-pass/</guid>
		<description><![CDATA[An interesting confluence of events this week takes me both back to the past as I ponder the future! What gives? Well, the recent release of Tomislav Piasevoli’s (blog&#124;twitter) new book, MDX with Microsoft SQL Server 2008 R2 Analysis Services Cookbook, reminded me of my first meeting with him at a PASS Summit event a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.packtpub.com/mdx-with-microsoft-sql-server-2008-r2-analysis-services/book?utm_source=blog.datainspirations.com&amp;utm_medium=bookrev&amp;utm_content=blog&amp;utm_campaign=mdb_009319"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; float: left; padding-top: 0px; border-width: 0px;" title="1308EN_MDX with Microsoft SQL Server Analysis Services 2008 R2 Cookbook" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/Back-to-the-Future-with-MDX-and-PASS_A4CA/1308EN_MDX-with-Microsoft-SQL-Server-Analysis-Services-2008-R2-Cookbook.png" border="0" alt="1308EN_MDX with Microsoft SQL Server Analysis Services 2008 R2 Cookbook" width="136" height="165" align="left" /></a>An interesting confluence of events this week takes me both back to the past as I ponder the future! What gives? Well, the recent release of Tomislav Piasevoli’s (<a href="http://tomislav.piasevoli.com/" target="_blank">blog</a>|<a href="http://twitter.com/tpiasevoli" target="_blank">twitter</a>) new book, <em><a href="http://www.packtpub.com/mdx-with-microsoft-sql-server-2008-r2-analysis-services/book?utm_source=blog.datainspirations.com&amp;utm_medium=bookrev&amp;utm_content=blog&amp;utm_campaign=mdb_009319" target="_blank">MDX with Microsoft SQL Server 2008 R2 Analysis Services Cookbook,</a></em> reminded me of my first meeting with him at a PASS Summit event a few years ago. Alas, I don’t remember which event because – I confess – I’m getting old and my brain just doesn’t store details like that anymore. Not when it’s full of more important tidbits more necessary to my daily work! If I had to guess, I think it was the first event that Erika attended with me, which means it would have been in 2008 but it could have been 2009, and definitely not 2010. How’s that for narrowing it down? [Edit: Tomislav reminded me that we actually met at the 2008 PASS Summit but we talked about the Axis function at the 2009 PASS Summit Birds of a Feather.]</p>
<p>Regardless of which year it was, Tomislav was seated at table during a Birds of a Feather lunch talking to several people about MDX, and he made a comment about the Axis function which I thought was very interesting. To be honest, I don’t remember what he said specifically, but it intrigued me enough to jot it down to pursue at a later time. It turned out not to be helpful for whatever MDX problem I was faced with at the time, but I kept the note to myself in my smartphone, which transferred over to the next two smartphones I’ve owned since then. My experience with MDX is that there are a handful of MDX functions that we who are inclined to write MDX use quite often. For an interesting, but entirely unscientific, analysis of function popularity, see this 2005 post from Mosha Pasumansky, “<a href="http://sqlblog.com/blogs/mosha/archive/2005/01/31/what-are-the-popular-mdx-functions.aspx">What are the popular MDX functions?</a>” Although the post is a bit dated, I think it’s still valid. When I look at the top list of functions, I do indeed use many of those functions frequently (although NonEmptyCrossJoin is deprecated and I now use the NonEmpty function instead).</p>
<p>This year, I finally found a situation where I found the <a href="http://msdn.microsoft.com/en-us/library/ms145531.aspx">Axis</a> function to be useful. Basically, this function gives us a way to “see” what’s currently on rows or columns. The situation facing me was  to come up with a way to create a calculation based on values found in two columns in a pivot table. More specifically, each column could be a different time period. So the calculation might be comparing Q1 and Q2 of a particular year, or it might be Q1 of one year and Q2 of another year. But we would not know in advance which two time periods would be involved. I built a calculation to count how many date members were on the columns axis and return a null if there were more than two, otherwise to do the math. I’ll provide the details for this in a separate post, but there are other scenarios in which this function is useful as Tomislav explains in this SQLBits session (recording freely accessible, slides and samples downloadable): <a href="http://sqlbits.com/Sessions/Event4/Universal_calculated_measures_in_MDX_queries">Universal calculated measures in MDX queries</a>.</p>
<p>That encounter with Tomislav is just one example of many that highlights the value of attending the <a href="http://www.sqlpass.org/summit/2011/">PASS Summit</a>. It’s not just what you learn by attending the sessions, but also what you learn in casual conversations with experts. Opportunities abound for these conversations, whether at a <a href="http://www.sqlpass.org/summit/2011/Connect/SpecialEvents.aspx#BOF_Lunch">Birds of a Feather</a> table or in the hallway or at one of the <a href="http://www.sqlpass.org/summit/2011/Connect/AfterHours.aspx">many evening events</a>. (Hint: Asking questions during <a href="http://www.sqlkaraoke.com/">SQLKaraoke</a> is probably not a good time.) People who are at PASS – both speakers and non-speakers alike – are there because they’re passionate about what they do. If you plan to go and it’s your first time, the best advice I can give is Don’t Be Shy! Talk to someone, anyone, everyone! You won’t regret it.</p>
<p>It’s only a few more short weeks until Erika and I head out to this year’s summit. I’ve got to finalize my demos for my preconference workshop on <a href="http://www.sqlpass.org/summit/2011/Speakers/CallForSpeakers/SessionDetail.aspx?sid=1491">MDX, DAX, and DMX</a> and for my half-day session with Denny Cherry, <a href="http://www.sqlpass.org/summit/2011/Speakers/CallForSpeakers/SessionDetail.aspx?sid=1134">So How Does the BI Workload Impact the Database Engine?.</a> I think all I need to do is show up for my panel session, <a href="http://www.sqlpass.org/summit/2011/Speakers/CallForSpeakers/SessionDetail.aspx?sid=1509">Are You a Linchpin?</a></p>
<p>Meanwhile, I’m going to be reading Tomislav’s new book to see what other gems he has to share, and I’ll post a review when I finish the book. Stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.datainspirations.com/2011/09/09/back-to-the-future-with-mdx-and-pass/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SQLU SSAS Week: Cube Deployment 101</title>
		<link>http://blog.datainspirations.com/2011/05/17/sqlu-ssas-week-cube-deployment-101/</link>
		<comments>http://blog.datainspirations.com/2011/05/17/sqlu-ssas-week-cube-deployment-101/#comments</comments>
		<pubDate>Tue, 17 May 2011 22:50:03 +0000</pubDate>
		<dc:creator>Stacia Misner</dc:creator>
				<category><![CDATA[Analysis Services]]></category>
		<category><![CDATA[SQL University]]></category>
		<category><![CDATA[SSAS]]></category>

		<guid isPermaLink="false">http://blog.datainspirations.com/2011/05/17/sqlu-ssas-week-cube-deployment-101/</guid>
		<description><![CDATA[This is the fifth and final post for SSAS week at SQL University. If you’re just joining the class, you should review the previous lessons first: Why Do I Need a Cube &#38; How Do I Get Started Dimension Design 101 Cube Construction 101 Cube Enhancements 101 Today, I’ll show you how to secure access [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://sqlchicken.com/sql-university" target="_blank"><img class="size-full wp-image-428 alignleft" title="SQL University" src="http://blog.datainspirations.com/wp-content/uploads/2011/05/SQL_University.png" alt="" width="175" height="200" /></a>This is the fifth and final post for SSAS week at <a href="http://sqlchicken.com/sql-university/" target="_blank">SQL University</a>. If you’re just joining the class, you should review the previous lessons first:</p>
<ul>
<li><a title="SQLU SSAS Week: Why Do I Need a Cube &amp; How Do I Get Started?" href="http://blog.datainspirations.com/2011/05/11/sqlu-ssas-week-why-do-i-need-a-cube-how-do-i-get-started/">Why Do I Need a Cube &amp; How Do I Get Started</a></li>
<li><a href="http://blog.datainspirations.com/2011/05/11/sqlu-ssas-week-dimension-design-101-2/">Dimension Design 101</a></li>
<li><a href="http://blog.datainspirations.com/2011/05/12/sqlu-ssas-week-cube-construction-101/">Cube Construction 101</a></li>
<li><a href="http://blog.datainspirations.com/2011/05/15/sqlu-ssas-week-cube-enhancements-101/">Cube Enhancements 101</a></li>
</ul>
<p>Today, I’ll show you how to secure access to the cube. I’ll also shed a little light on what happens when you deploy a cube, and I’ll wrap up this week’s lesson by explaining different ways that people might access a cube. There is so much more to learn about cubes when you have advanced analytical needs to support, but at the conclusion of this series you will have a grasp of the important concepts which is enough to get started with simple analytical requirements.</p>
<h3>Security</h3>
<p>Right now, you’re the only person who can browse the cube because you’re the one who created it. Before other people can browse the cube, you need to grant them the necessary permissions. Analysis Services supports only Windows integrated security, so everyone requiring access to the cube must have a Windows account. Rather than assign permissions to individual users, you might consider creating a Windows group and assigning users to that group.</p>
<p>Let’s assume that you have created a Windows group called SSAS and you’re now ready to set up security for your cube. Open your project in BIDS, right-click the <strong>Roles</strong> folder, and select <strong>New Role</strong>. The default name of the role is Role, but you can change that later if you like. Open the second tab in the role designer, <strong>Membership</strong>, and click the <strong>Add</strong> button. Locate the SSAS group to add the group to the role. Then go to the <strong>Cube </strong>tab and select <strong>Read </strong>in the <strong>Access </strong>drop-down list. In most cases, this step is the only one you need to perform. After you deploy the cube, anyone in the group can browse the cube using their tool of choice (which is not BIDS; BIDS is used by developers only).</p>
<p>Analysis Services also allows you to apply more granular permissions. For example, you can prevent users from viewing specific members in a dimension, such as the Mountain Bikes subcategory. You even prevent users from viewing certain cell values, such as the Sales Amount Quota for the AWC Logo Cap in 2008. As you might imagine, the subject of security is pretty deep and beyond the scope of what I can cover in an introductory course in SQL University. So instead, I’ll refer you to <a href="http://msdn.microsoft.com/en-us/library/ms175408.aspx" target="_blank">Granting User Access</a> for an overview of security concepts in Analysis Services. For data-driven security, take a look at <a href="http://gavinrussell.wordpress.com/2010/05/07/analysis-services-%E2%80%93-data-driven-security-model/" target="_blank">Analysis Services—Data Driven Security Model</a>.</p>
<h3>Deployment</h3>
<p>Throughout this course, I have asked you to deploy your project to make it available for browsing. The Deploy command in BIDS actually performs three steps for you that can be performed individually by using alternative means:</p>
<ol>
<li><strong>Build</strong> – In this step, BIDS combines all the files in your project (data source, DSV, cube, dimensions, etc.) and creates a single file that has the <strong>asdatabase</strong> extension. Essentially, it’s one giant XML file that contains all the definitions about database objects that you see as individual files in BIDS. It’s very common in production environments that developers cannot deploy objects themselves, but instead provide files and scripts for administrators to perform the deployment. If necessary, you can use the Build command in BIDS to generate the asdatabase file and deliver it to your administrator.</li>
<li><strong>Deploy</strong> – The administrator copies the asdatabase file to a location on the server hosting Analysis Services. Then, from the Microsoft SQL Server 2008 R2\Analysis Services program group, the administrator launches <strong>Deployment Wizard</strong>. (You can learn more about the wizard at Using the <a href="http://msdn.microsoft.com/en-us/library/ms176121.aspx" target="_blank">Analysis Services Deployment Wizard</a>.) This wizard steps through the process of taking the asdatabase file from its current location, and moving it to the OLAP data folder of the Analysis Services instance where the file gets “unbundled” into separate database object files, just like the ones you had in BIDS.</li>
<li><strong>Process</strong> – The presence of the database object files is not enough to render the cube usable. Processing must take place first. Processing reads the definition files to determine how to get to the source data, how to query the data, and how to load the data into the structures that Analysis Services requires. After processing completes successfully, everyone (with permissions, of course!) can browse the cube.</li>
</ol>
<h3>Processing</h3>
<p>You can connect to Analysis Services by using SQL Server Management Studio (SSMS), and then use Object Explorer to locate a database for processing. You can even access individual measure groups or dimensions for processing. There are different types of processing that you can do. When you’re still learning about Analysis Services, it’s generally best to do a full process of dimensions and then a full process of cubes. When you perform a full process of any dimension, each cube with which it’s associated will also require a full process and the cube will be unavailable to users during this time. As you learn more, you’ll find that you can perform other types of processing that keep the cube available, but require more thought about data preparation. An overview of processing options is available at <a href="http://msdn.microsoft.com/en-us/library/ms175634.aspx" target="_blank">Processing (Analysis Services – Multidimensional Data).</a></p>
<p>Usually, it’s not practical to process manually in SSMS every time that you want to refresh the cube. Most people create an Integration Services package that contains one or more <a href="http://technet.microsoft.com/en-us/library/ms141779.aspx" target="_blank">Analysis Services Processing Tasks</a>, and then schedule the package to run on a periodic basis.</p>
<h3>User Access</h3>
<p>Once a cube is deployed and processed, users with the appropriate permissions can connect to the cube and browse to their hearts’ content. Using what? Whatever Analysis Services client they have available. Most organizations that have Analysis Services in-house also have Microsoft Office. Users can create pivot tables to explore data in a cube. The user experience in Excel 2003 is not so great, but Excel 2007 or Excel 2010 work similarly.</p>
<p>Assuming you are using Excel 2007 or higher, you must create an Office Data Connection (ODC) file – or open an ODC file – first. To create the ODC file, click <strong>From Other Sources </strong>on the <strong>Data </strong>tab of the ribbon, and then select <strong>From Analysis Services</strong>. Provide the server name (or localhost) and click Next. Then select your database—My SSAS DB—and the cube—Sales—and click Next. You can use the Browse button to save the ODC file in a specific place, either a local drive for personal use or a SharePoint Data Connections library for shared use.</p>
<p>When you save an ODC file to SharePoint, it can be used for workbooks accessed using Excel Services, or for status indicators (aka KPIs) or Filter Web Parts in SharePoint. Working with ODC files for Analysis Services sources and configuring SharePoint to authenticate with Analysis Services correctly can be tricky. You can learn more at <a href="http://msdn.microsoft.com/en-us/library/ff604007.aspx" target="_blank">Plan Excel Services data sources and external connections (SharePoint Server 2010).</a> If you’re using SharePoint 2007, refer to <a href="http://technet.microsoft.com/en-us/library/cc262899(office.12).aspx" target="_blank">Plan external data connections for Excel Services</a> instead.</p>
<p>Regardless of where you save the ODC file, you use it as the source for a pivot table. In fact, after following the steps above and right after saving the file, you’re prompted for the location in which a pivot table will be inserted. On the right side, you should see the PivotTable Field list which displays all the measures by measure group, followed by KPIs and dimensions. All you need to do is select checkboxes for items that you want to display in the PivotTable, such as <strong>Internet Sales Amount</strong>, and <strong>Reseller Sales Amount. </strong>Expand the KPIs folder to add the following: <strong>Value, Goal, Status, </strong>and <strong>Trend</strong>. Also add <strong>Date.Calendar</strong>. Click the plus sign next to <strong>2008</strong> and <strong>2008 Q1</strong> to drill down to months. Your pivot table will look like this:</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Cube-Deployment-101_6C31/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/SQLU-SSAS-Week-Cube-Deployment-101_6C31/image_thumb.png" border="0" alt="image" width="509" height="198" /></a></p>
<p>The KPIs aren’t very interesting with this data set because the total sales in the cube always exceeds the goal except when you drill down to months. The goal comes from the FactSalesQuota and is associated with quarters, but those quarters are referenced by the first day of the quarter, such as January 1, 2008, so the goal for January shown here is really a quarterly goal. There are tricks that we can use to either hide that value at the month level or to spread the quarterly amount across months in some way, but that’s beyond the scope of this week’s lessons. Hint for the curious: you have to add expressions to the MDX Script.</p>
<p>The selections you make in the PivotTable Field list appear below the list as objects that you can rearrange as desired. You can move dimensions from row labels to column labels or to the report filter. You can also drag the measures in the Values box to a higher or lower position to re-sequence the measures any way you like.</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Cube-Deployment-101_6C31/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/SQLU-SSAS-Week-Cube-Deployment-101_6C31/image_thumb_3.png" border="0" alt="image" width="178" height="156" /></a></p>
<p>Remember in a previous lesson that you added an action to the cube. Let’s see how that works now. Right-click on one of the cells in the pivot table – such as the value <strong>$1,340,244.95</strong> at the intersection of <strong>Jan 2008</strong> and <strong>Internet Sales Amount</strong>, then point to <strong>Additional Actions</strong>, and then click on <strong>Internet Sales Details</strong>.</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Cube-Deployment-101_6C31/image_4.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/SQLU-SSAS-Week-Cube-Deployment-101_6C31/image_thumb_4.png" border="0" alt="image" width="404" height="220" /></a></p>
<p>The action definition shows only the columns that you defined for the drillthrough action:</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Cube-Deployment-101_6C31/SNAGHTML73125ae.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="SNAGHTML73125ae" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Cube-Deployment-101_6C31/SNAGHTML73125ae_thumb.png" border="0" alt="SNAGHTML73125ae" width="578" height="159" /></a></p>
<p>Excel also has a built-in drillthrough functionality that you can launch by just by double-click a cell value—as long as it’s not a calculated measure. The difference between the built-in functionality and the drillthrough action is that you have control over the columns that appear in the drillthrough action. It’s better when there is a specific set of columns that users want to see all the time, and is useful when you have a lot of columns available in a measure group and just want to focus on a subset of columns.</p>
<p>Your cube is also accessible for use with other tools. If you have a Reporting Services instance, users can launch Report Builder, select the Microsoft SQL Server Analysis Services provider type to create a data source, and then create a dataset using a <a href="http://msdn.microsoft.com/en-us/library/dd220489.aspx" target="_blank">designer interface</a> that lets them use drag-and-drop to select the dimensions and measures they want to include in the report. User can also <a href="http://office.microsoft.com/en-us/sharepoint-server-help/getting-started-with-sharepoint-status-indicators-HA010380634.aspx" target="_blank">create status indicators from a cube</a> for use in lists or SharePoint dashboards by using ODC files. If users want to access cube data in PerformancePoint Services scorecards and dashboards, a separate <a href="http://technet.microsoft.com/en-us/library/ff191198.aspx" target="_blank">data connection for Analysis Services</a> must be created.</p>
<h3>Learning More</h3>
<p>By completing the lessons in this introductory course to Analysis Services, you have the basic knowledge necessary to build simple cubes. But there is so much more to learn! Keep an eye on this blog as I’ll post topics related to Analysis Services from time to time, and of course <a href="http://sqlchicken.com/sql-university/" target="_blank">SQL University</a> will offer intermediate and advanced lessons in future semesters.</p>
<p>If your measure group contains fewer than 20 million rows, such as our sample cube from the lessons this past week, then you don’t need to worry about scaling the cube. Most business data these days contains many millions of rows, so enhancing the cube with scalability features is often the next step. The first step towards scaling is the addition of aggregations which you can learn more about by reading <a href="http://www.jenstirrup.com/2009/04/optimising-aggregations-in-analysis.html" target="_blank">Optimising Aggregations in Analysis Services 2008</a>. Another option to use, often hand in hand with aggregations, is the implementation of <a href="http://msdn.microsoft.com/en-us/library/ms175688.aspx" target="_blank">partitions</a>.</p>
<p>A good online resource for all things related to Analysis Services is the <a href="http://ssas-info.com/" target="_blank">Analysis Services Resource Hub</a>. If you like to learn from books, here are several that I recommend:</p>
<ul>
<li><a href="http://www.amazon.com/Microsoft%C2%AE-Server%C2%AE-Analysis-Services-Microsoft/dp/0735626200/ref=sr_1_1?ie=UTF8&amp;qid=1305671816&amp;sr=8-1" target="_blank">Microsoft SQL Server 2008 Analysis Services 2008 Step by Step</a> by Scott Cameron, who started his BI career with me back in 1999.</li>
<li><a href="http://www.amazon.com/Professional-Microsoft-Analysis-Services-Programmer/dp/0470247983/ref=sr_1_1?s=books&amp;ie=UTF8&amp;qid=1305671980&amp;sr=1-1" target="_blank">Professional Microsoft SQL Server Analysis Services 2008 with MDX</a> by a line-up of Microsoft folks: Sivakumar Harinath, Robert Zare, Sethu Meenakshisundaram (who later went to SAP), Matt Carroll, and Denny Guang-Yeu Lee. Denny and I shared an office once upon a time before he joined Microsoft. It was entertaining, to say the least!</li>
<li><a href="http://www.amazon.com/Expert-Development-Microsoft-Analysis-Services/dp/1847197221/ref=sr_1_2?ie=UTF8&amp;qid=1305672210&amp;sr=8-2" target="_blank">Expert Cube Development with Microsoft SQL Server 2008 Analysis Services</a> by SQL Server MVPs and friends Marco Russo, Alberto Ferrari, and Chris Webb.</li>
<li>When you’re ready for advanced (really advanced!) material, tackle <a href="http://www.amazon.com/Microsoft-Server-Analysis-Services-Unleashed/dp/0672330016/ref=sr_1_5?ie=UTF8&amp;qid=1305672210&amp;sr=8-5" target="_blank">Microsoft SQL Server 2008 Analysis Services Unleashed</a> by Microsoft developers who worked on the product, Irina Gorbach, Alexander Berger, and Edward Melomed. This book is required reading if you want to become an <a href="http://sqlcat.com/msdnmirror/archive/2011/05/11/announcing-ssas-maestros-v1-2.aspx" target="_blank">SSAS Maestro</a>!</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.datainspirations.com/2011/05/17/sqlu-ssas-week-cube-deployment-101/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SQLU SSAS Week: Cube Enhancements 101</title>
		<link>http://blog.datainspirations.com/2011/05/15/sqlu-ssas-week-cube-enhancements-101/</link>
		<comments>http://blog.datainspirations.com/2011/05/15/sqlu-ssas-week-cube-enhancements-101/#comments</comments>
		<pubDate>Sun, 15 May 2011 14:07:35 +0000</pubDate>
		<dc:creator>Stacia Misner</dc:creator>
				<category><![CDATA[Analysis Services]]></category>
		<category><![CDATA[SQL University]]></category>
		<category><![CDATA[SSAS]]></category>

		<guid isPermaLink="false">http://blog.datainspirations.com/2011/05/15/sqlu-ssas-week-cube-enhancements-101/</guid>
		<description><![CDATA[This is the fourth post for SSAS week at SQL University. Here’s the coursework so far: Why Do I Need a Cube &#38; How Do I Get Started Dimension Design 101 Cube Construction 101 In today’s post, I will show how you to correct problems that you discover in dimensions after you deploy the database [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://sqlchicken.com/sql-university" target="_blank"><img class="size-full wp-image-428 alignleft" title="SQL University" src="http://blog.datainspirations.com/wp-content/uploads/2011/05/SQL_University.png" alt="" width="175" height="200" /></a>This is the fourth post for SSAS week at <a href="http://sqlchicken.com/sql-university/" target="_blank">SQL University</a>. Here’s the coursework so far:</p>
<ul>
<li><a title="SQLU SSAS Week: Why Do I Need a Cube &amp; How Do I Get Started?" href="http://blog.datainspirations.com/2011/05/11/sqlu-ssas-week-why-do-i-need-a-cube-how-do-i-get-started/">Why Do I Need a Cube &amp; How Do I Get Started</a></li>
<li><a href="http://blog.datainspirations.com/2011/05/11/sqlu-ssas-week-dimension-design-101-2/">Dimension Design 101</a></li>
<li><a href="http://blog.datainspirations.com/2011/05/12/sqlu-ssas-week-cube-construction-101/">Cube Construction 101</a></li>
</ul>
<p>In today’s post, I will show how you to correct problems that you discover in dimensions after you deploy the database and how to enhance the cube by adding another measure group as well as adding special features, such as key performance indicators and actions.</p>
<h3><img src="http://blog.datainspirations.com/wp-content/uploads/2010/11/57c69da7747d_3D0F/SNAGHTML23c9eaa_thumb1_thumb.png" alt="" />Step 0: Dimension Cleanup</h3>
<p>In the previous lesson, you deployed the cube and browsed the results. Everything looked good except for category and subcategory attributes, whether individually or as levels in the Products hierarchy of the Product dimension. Your task was to figure out why you the labels didn’t display correctly and to fix it.</p>
<p>Now for the solution. Remember that each attribute has a <strong>KeyColumns</strong> property and a <strong>NameColumn</strong> property. Unless you specify the <strong>NameColumn </strong>explicitly, the dimension will display the value in the <strong>KeyColumns </strong>when you’re browsing that attribute in a metadata list or in the cube. To fix the problem, just set the <strong>NameColumn </strong>property to <strong>EnglishProductCategoryName </strong>for the <strong>Category </strong>attribute and set the same property for the <strong>Subcategory </strong>attribute to <strong>EnglishProductSubcategoryName</strong>.</p>
<p>Deploy the project, and then browse the cube again to check the results. You need to click the <strong>Reconnect</strong> button to see the labels change. You can also use the <strong>Browser </strong>tab in the dimension designer to view labels in each attribute hierarchy or user-defined hierarchy if you prefer.</p>
<h3><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Cube-Enhancements-101_B0C5/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/SQLU-SSAS-Week-Cube-Enhancements-101_B0C5/image_thumb.png" border="0" alt="image" width="22" height="16" /></a>Step 1: Additional Measure Group</h3>
<p>It’s a common practice to build a cube incrementally. That means you don’t need to have all your measure groups available at the same time before you can design the cube or even to make it available to users. Today you’re going to add a third measure group for Sales Amount Quota so that the cube supports comparisons of actual sales to the quotas.</p>
<p>Nothing makes it into a cube or dimension without coming through the DSV, so open the DSV file in your project. Right-click on the DSV background and select <strong>Add/Remove Tables</strong>. Locate the <strong>FactSalesQuota </strong>table and add it to your DSV. The foreign key relationship to the Date dimension is added automatically. The fact table also has a relationship to the Employee dimension which we’re ignoring in this week’s lesson. After we add the fact table as an additional measure group to the cube, we’ll be able to slice and dice the quota data only by date. Be sure to rename the table to <strong>SalesQuota </strong>before continuing, just like you did for <strong>InternetSales </strong>and <strong>ResellerSales</strong>.</p>
<p>To add the quota data to the cube, you need to open the cube designer. In the Measures pane in the top left corner of the designer, right-click the <strong>Sales</strong> cube, and select <strong>New Measure Group</strong>. Then you can add <strong>SalesQuota</strong>.However, adding the entire measure group adds all the numeric columns as measures, so you can switch to the grid view to multi-select the unneeded columns. When finished, the Sales Quota measure group should have only one measure: <strong>Sales Amount Quota</strong>. Tip: An alternative approach would be to use the New Measure command when you right-click the cube, and then use a dialog box to select the measure that you want to add.</p>
<p>Be sure to set the format string to Currency. Deploy the project, and then browse the cube by adding the following measures to the grid: <strong>Sales Amount</strong> and <strong>Sales Amount Quota</strong>. Then add <strong>Date.Calendar </strong>to rows like this:</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Cube-Enhancements-101_B0C5/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/SQLU-SSAS-Week-Cube-Enhancements-101_B0C5/image_thumb_3.png" border="0" alt="image" width="305" height="139" /></a></p>
<p>Notice anything strange here? Such as the repeating values in the Sales Amount columns? Remember from the previous lesson that Sales Amount combines values from the Reseller Sales and Internet Sales measure groups. But, you can’t slice that value by date without making another change to the cube.</p>
<p>You also have some other date dimensions available – Order Date, Due Date, and Ship Date – which allow you to slice by Sales Amount, but not by Sales Amount Quota. In order to calculate the variance between Sales Amount and Sales Amount Quota, you need to be able to slice both measures at once.</p>
<h3><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Cube-Enhancements-101_B0C5/SNAGHTML60251e.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="SNAGHTML60251e" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Cube-Enhancements-101_B0C5/SNAGHTML60251e_thumb.png" border="0" alt="SNAGHTML60251e" width="20" height="18" /></a> Step 2: Dimension Usage</h3>
<p>The ability to slice and dice a measure by a dimension member is determined by the relationship that exists between measure groups and dimensions. That type of relationship is managed on the Dimension Usage tab of the cube designer. It’s usually inherited from the foreign key relationship found in the DSV when you use the cube wizard, but it’s ignored when you manually add a measure group. The gray box at the intersection of a dimension and measure group indicates a relationship does not exist.</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Cube-Enhancements-101_B0C5/SNAGHTML70e457.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="SNAGHTML70e457" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Cube-Enhancements-101_B0C5/SNAGHTML70e457_thumb.png" border="0" alt="SNAGHTML70e457" width="363" height="118" /></a></p>
<p>To add a missing relationship, click the gray box (such as the one at the intersection of <strong>Internet Sales </strong>and <strong>Date</strong>), and click the ellipsis button that appears there. Most of the time, you define the relationship here as the <strong>Regular </strong>relationship type. The other types are for advanced scenarios that we won’t be covering in this course, but if you’re really curious, you can learn more at <a href="http://msdn.microsoft.com/en-us/library/ms175669.aspx" target="_blank">Dimension Relationships</a>.</p>
<p>Then you specify the level of detail in the dimension that relates to the measure group. For example, the Internet Sales measure group relates to the Date dimension at the Date level. So set Granularity Attribute to <strong>Date</strong> and set Measure Group Columns to <strong>OrderDateKey</strong>. In this cube, once its deployed after adding this relationship, the use of either the Date dimension or the Order Date dimension will yield similar results.</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Cube-Enhancements-101_B0C5/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/SQLU-SSAS-Week-Cube-Enhancements-101_B0C5/image_thumb_4.png" border="0" alt="image" width="424" height="281" /></a></p>
<p>Next, repeat the process above to add a relationship between Reseller Sales and Date. Then add a third relationship between Sales Amount Quota and Date (Order Date). (You’ll use DateKey for the Measure Group Columns value in the latter case.) That way, whether users select Date or Order Date for slicing, they can compare values between actual sales and the quotas.</p>
<p>Why not eliminate all the extra dates? Aren’t they confusing? Well, it depends. If users will never analyze data using Ship Dates or Due Dates, then you can safely delete the three <a href="http://en.wikipedia.org/wiki/Dimension_(data_warehouse)#Role-playing_dimensions" target="_blank">role-playing dimensions</a> from the cube on the cube designer page (in the bottom left corner on the Cube Structure tab). You&#8217;ll still have the Date dimension available for time-series analysis and time-based slice-and-dice. On the other hand, you might want to retain Order Date along with Date in the cube if there’s a possibility that you will add another measure group that relies on Date but has no relationship whatsoever to Order Date. (That scenario doesn’t exist in the Adventure Works sample data, incidentally.)</p>
<h3><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Cube-Enhancements-101_B0C5/SNAGHTML34c12d.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="SNAGHTML34c12d" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Cube-Enhancements-101_B0C5/SNAGHTML34c12d_thumb.png" border="0" alt="SNAGHTML34c12d" width="20" height="20" /></a> Step 3: Key Performance Indicator</h3>
<p>Another way to enhance a cube is to add key performance indicators (KPIs). A KPI is a group of calculations that you use to compare a value to a target. Client tools for Analysis Services can display the results of this comparison using different images that are associated with a positive, neutral, or negative status. In addition, the KPI includes a trend calculation used to show whether the value is increasing or decreasing as compared to a previous point in time. For example, you can set up a KPI to compare sales amounts to quotas by adding the expressions on the KPIs tab of the cube designer.</p>
<p>Click the KPIs tab which is the fourth tab from the left. Click the <strong>New KPI </strong>button (the fifth button from the left). In the form that displays, type a name—<strong>Quota</strong>—and then add the following expression in the Value Expression box:</p>
<p><span style="font-family: 'Courier New';">[Measures].[Sales Amount] </span></p>
<p>The Value Expression can also be an MDX expression that resolves to a number, but this is a simple example that relies on values found in the fact tables. Next, add the Goal Expression like this:</p>
<p><span style="font-family: 'Courier New';">[Measures].[Sales Amount Quota] </span></p>
<p>In the Status Indicator drop-down list, you choose an image to represent the current result of comparing Sales Amount to Sales Amount Quota. For this cube, use Shapes. Then enter the Status expression which is used to determine which shape to display. There are three possible shapes, so you need an expression that resolves as one of three possible values which effectively mean “meeting goal”, “progressing towards goal”, and “not meeting goal.” We use 1, 0, and –1 to reflect those three values respectively. For the purposes of this lesson, assume that 1 means the sales are equal to or better than 90% of the target. Otherwise, 60% of the target is represented by a value of 0, and everything else is –1. The expression to produce these results looks like this:</p>
<p><span style="font-family: 'Courier New';">iif([Measures].[Sales Amount] &gt;= [Measures].[Sales Amount Quota] * .9, 1, iif ([Measures].[Sales Amount] &gt;= [Measures].[Sales Amount Quota] * .6, 0, -1))</span></p>
<p>The Trend expression is similar to status because it is used to determine a shape to display, but in this case the shape is an arrow and the expression requires a comparison between one time period and another. The result of the Trend expression determines what direction the arrow points—up (or 1) for upward trends, flat (or 0) for no change in trend, and down (or –1) for downward trends. The following trend expression compares the current variance to the variance for the previous year.</p>
<p><span style="font-family: 'Courier New';">Case<br />
When IsEmpty(ParallelPeriod([Order Date].[Calendar Year].[Calendar Year],<br />
1, [Order Date].[Calendar Year]))<br />
Then 0<br />
When ([Measures].[Sales Amount] &#8211; [Measures].[Sales Amount Quota]) &gt;<br />
((ParallelPeriod([Order Date].[Calendar Year].[Calendar Year],<br />
1, [Order Date].[Calendar Year]), [Measures].[Sales Amount]) -<br />
(ParallelPeriod([Order Date].[Calendar Year].[Calendar Year],<br />
1, [Order Date].[Calendar Year]), [Measures].[Sales Amount Quota]))<br />
Then 1<br />
When ([Measures].[Sales Amount] &#8211; [Measures].[Sales Amount Quota]) =<br />
((ParallelPeriod([Order Date].[Calendar Year].[Calendar Year],<br />
1, [Order Date].[Calendar Year]), [Measures].[Sales Amount]) -<br />
(ParallelPeriod([Order Date].[Calendar Year].[Calendar Year],<br />
1, [Order Date].[Calendar Year]), [Measures].[Sales Amount Quota]))<br />
Then 0<br />
Else -1<br />
End</span></p>
<p>We’ll see how to view KPIs in the next post in this course.</p>
<h3><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Cube-Enhancements-101_B0C5/image_5.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/SQLU-SSAS-Week-Cube-Enhancements-101_B0C5/image_thumb_5.png" border="0" alt="image" width="20" height="18" /></a>Step 4: Action</h3>
<p>Another type of enhancement you can add to a cube is an action. There are three types of actions:</p>
<ul>
<li><strong>URL action –</strong> to navigate to a specific Web page, such as a Product Catalog page for a product selected in a cube.</li>
<li><strong>Reporting action –</strong> to open a Reporting Services report, such as a Sales Order Details report for a customer selected in a cube.</li>
<li><strong>Drillthrough action –</strong> to display in an HTML page the detailed data associated with a selected measure in a cube. (The measure must come from a measure group, and cannot be a calculation.)</li>
</ul>
<p>Go to the Actions tab of the cube designer to define actions and related properties. Click the <strong>New Drillthrough Action </strong>button in the toolbar (the sixth one from the left). Name it <strong>Internet Sales Details </strong>and select <strong>Internet Sales </strong>as the action target. In the Drillthrough Columns section, select the following columns by dimension:</p>
<ul>
<li>Order Date: Date</li>
<li>Product: Product, Subcategory, Category</li>
<li>Measures: Internet Sales Amount, Internet Order Quantity</li>
</ul>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Cube-Enhancements-101_B0C5/image_6.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/SQLU-SSAS-Week-Cube-Enhancements-101_B0C5/image_thumb_6.png" border="0" alt="image" width="415" height="112" /></a></p>
<p>Deploy your cube. You’ll see how to use the action in the next post.</p>
<h3>What’s Next?</h3>
<p>Now you have a basic but fully functioning cube. In our next lesson of the week, <a title="SQLU SSAS Week: Cube Deployment 101" href="http://blog.datainspirations.com/2011/05/17/sqlu-ssas-week-cube-deployment-101/">Cube Deployment 101</a>, I’ll explain how to implement security and how to provide users access to your cube.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.datainspirations.com/2011/05/15/sqlu-ssas-week-cube-enhancements-101/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>SQLU SSAS Week: Cube Construction 101</title>
		<link>http://blog.datainspirations.com/2011/05/12/sqlu-ssas-week-cube-construction-101/</link>
		<comments>http://blog.datainspirations.com/2011/05/12/sqlu-ssas-week-cube-construction-101/#comments</comments>
		<pubDate>Thu, 12 May 2011 12:00:52 +0000</pubDate>
		<dc:creator>Stacia Misner</dc:creator>
				<category><![CDATA[Analysis Services]]></category>
		<category><![CDATA[SQL University]]></category>
		<category><![CDATA[SSAS]]></category>

		<guid isPermaLink="false">http://blog.datainspirations.com/?p=469</guid>
		<description><![CDATA[This is the third post for SSAS week at SQL University. If you’re just joining the class, refer to Why Do I Need a Cube &#38; How Do I Get Started and Dimension Design 101 to get caught up.  At this point, my expectation is that you have an Analysis Services project with at least [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://sqlchicken.com/sql-university" target="_blank"><img class="size-full wp-image-428 alignleft" title="SQL University" src="http://blog.datainspirations.com/wp-content/uploads/2011/05/SQL_University.png" alt="" width="175" height="200" /></a>This is the third post for SSAS week at <a href="http://sqlchicken.com/sql-university/" target="_blank">SQL University</a>. If you’re just joining the class, refer to <a title="SQLU SSAS Week: Why Do I Need a Cube &amp; How Do I Get Started?" href="http://blog.datainspirations.com/2011/05/11/sqlu-ssas-week-why-do-i-need-a-cube-how-do-i-get-started/">Why Do I Need a Cube &amp; How Do I Get Started</a> and <a href="http://blog.datainspirations.com/2011/05/11/sqlu-ssas-week-dimension-design-101-2/">Dimension Design 101</a> to get caught up.  At this point, my expectation is that you have an Analysis Services project with at least two dimensions designed—Date and Product. Now you’re ready to build the cube itself. In a later post, I’ll discuss various cube enhancements that you can make, security measures to implement, and tools that enable user access to cube data.</p>
<h3><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Cube-Construction-101_6D94/SNAGHTML476c410.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="SNAGHTML476c410" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Cube-Construction-101_6D94/SNAGHTML476c410_thumb.png" border="0" alt="SNAGHTML476c410" width="15" height="16" /></a> Step 1: Cube Wizard</h3>
<p>By now, you can probably guess how to launch the cube wizard. Right-click the Cubes folder in Solution Explorer, and click <strong>New Cube</strong>. For creation method, select the <strong>Use existing tables </strong>option. Then you need to specify the measure group tables. Measure group tables are equivalent to fact tables because, after all, fact tables are simply tables that contain groups of measures (the values that people will analyze). There are two measure group tables for this cube: <strong>InternetSales</strong> and <strong>ResellerSales</strong>.On the next page of the wizard, you see a list of all columns with numeric values which are presented as candidate measures. Some of them are just foreign key columns which you can ignore. (If the wizard could figure everything out, why would we need you?)</p>
<p>Clear the <strong>Measures </strong>checkbox at the top, and then select the following measures from the <strong>Internet Sales </strong>measure group: <strong>Order Quantity</strong> (which you rename as <strong>Internet Order Quantity</strong>), <strong>Total Product Cost </strong>(which you should rename here as <strong>Internet Cost</strong>), <strong>Sales Amount </strong>(which you should rename as <strong>Internet Sales Amount</strong>). To rename measures here, just right-click the measure name and type in the revised name.</p>
<p>Next, select the following measures from the <strong>Reseller Sales </strong>measure group: <strong>Order Quantity</strong> (which you rename as <strong>Reseller Order Quantity</strong>), <strong>Total Product Cost – Reseller Sales </strong>(which you should rename as <strong>Reseller Cost</strong>), <strong>Sales Amount – Reseller Sales </strong>(which you should rename as <strong>Reseller Sales Amount</strong>).</p>
<p>Continuing through the wizard, you get a chance to select existing dimensions. These are the dimensions that you’ve already created—Date and Product. The wizard detected the foreign key relationships in the DSV and the existence of the dimension objects in the project.</p>
<p>On the next page of the wizard, it volunteers to create two more dimensions for you—Internet Sales and Reseller Sales. Clear the Dimension checkbox at the top to skip this step. The technical term for these two dimensions is <a href="http://en.wikipedia.org/wiki/Degenerate_dimension" target="_blank">degenerate dimension</a>. There are a lot of steps required to properly configure a degenerate dimension in a cube which I won’t cover this week, and it’s not commonly used (at least not in the projects I’ve done over the past 10 years, so maybe it’s just not commonly used by me…).</p>
<p>At the end of the wizard steps, you get the chance to name the cube. Let’s keep the name simple: <strong>Sales</strong>. And now, when you complete the wizard, you have a cube!</p>
<h3><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Cube-Construction-101_6D94/SNAGHTML5271b09.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="SNAGHTML5271b09" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Cube-Construction-101_6D94/SNAGHTML5271b09_thumb.png" border="0" alt="SNAGHTML5271b09" width="22" height="14" /></a> Step 2: Format Strings</h3>
<p>The first thing I always do after I create a cube is configure the format strings for the measures, so that’s what I want you to do next. It’s a good habit to develop because you’ll be browsing the cube to test it soon and it will be easier to review values if they’re already formatted.</p>
<p>On the Cube Structure tab of the cube designer, you can see your measures in the top left corner. Actually, you first see the measure groups, Internet Sales and Reseller Sales, which you can expand to see the measures. You can select each measure one by one and set the FormatString property individually, or you can apply the format string in bulk. Let’s do that.</p>
<p>Click the fifth button from the left  to show measures in a grid. Then, while you press and hold the Ctrl key, select <strong>Internet Order Quantity </strong>and <strong>Reseller Order Quantity</strong>. In the Properties window, locate the <strong>FormatString</strong> property and type <strong>#,#</strong>. That will set the quantities to display as integers with thousands separators and no decimal places. Now select the remaining measures and select <strong>Currency </strong>in the drop-down list for the <strong>FormatString </strong>property.</p>
<h3><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Cube-Construction-101_6D94/SNAGHTML5266226.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="SNAGHTML5266226" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Cube-Construction-101_6D94/SNAGHTML5266226_thumb.png" border="0" alt="SNAGHTML5266226" width="14" height="16" /></a> Step 3: Calculations</h3>
<p>In the first post, I mentioned that one benefit of cubes is the centralization of business logic. You’ll need to learn MDX to create complex calculations, but I’ll show you how to build a simple one to whet your appetite for more! If you like to learn from books, check out <a href="http://www.amazon.com/Microsoft%C2%AE-Server%C2%AE-2008-Step-Microsoft/dp/0735626189" target="_blank">MDX Step by Step</a>. Otherwise, a good online resource begins at <a href="http://www.databasejournal.com/features/mssql/article.php/1495511/MDX-at-First-Glance-Introduction-to-SQL-Server-MDX-Essentials.htm" target="_blank">MDX at First Glance: Introduction to SQL Server MDX Essentials</a> by William Pearson. Pearson has a whole series of articles that follow this introduction to MDX. Although it’s a bit dated because the language has changed a bit since the article was written (and you can  now use Management Studio to write MDX), most of the principles still apply. The main thing to know is that instead of referencing a dimension member like [Date].[CY 2005] in Dimension.Member format, you use [Date].[Calendar Year].[CY 2005] in Dimension.Hierarchy.Member format.</p>
<p>For your Sales cube, add a simple calculation to combine the sales for Internet and reseller sales. In the Cube Designer that displays when you close the wizard (or if necessary, double-click Sales.cube in Solution Explorer), click the Calculations tab which is the third tab from the left. Click the <strong>New Calculated Member</strong> button (the fifth button from the left). In the form that displays, type a name—<strong>[Sales Amount]</strong>—and then add the following expression:</p>
<p><span style="font-family: 'Courier New';">[Measures].[Internet Sales Amount] + [Measures].[Reseller Sales Amount]</span></p>
<p>This expression does what it looks like it does – adds together the two sales amount to produce a grand total, no matter how much you are slicing and dicing the cube. (If you don’t know what that means, hang on – I’ll show you later!)</p>
<p>Set a format string for the calculation by selecting <strong>“Currency” </strong>in the drop-down list. Now create two more measures, <strong>Order Quantity </strong>and <strong>Cost</strong>, to combine order quantities and costs from the two measure groups like you did for sales amounts. Remember to set the format strings appropriately. Tip: You’ll need to use <strong>“#,#” </strong>instead of <strong>#,# </strong>here for <strong>Order Quantity</strong>.</p>
<h3>Step 4: Browse</h3>
<p>Now is a good time to do some good ol’ slice and dice to see if the cube behaves as expected and returns correct results. But first you need to deploy the changes that you made just like we did in the <a href="http://blog.datainspirations.com/2011/05/11/sqlu-ssas-week-dimension-design-101-2/">Dimension Design 101</a> lesson. Then when deployment completes successfully, click the Browser tab (the very last one) in the cube designer. From the metadata tree  on the left, drag <strong>Measures </strong>to the area of the grid labeled <strong>Drop Totals or Detail Fields Here</strong>. All the measures from the fact tables and the calculations appear in the grid.</p>
<p>Next, expand Order Date and drag Order Date.Calendar to the area of the grid labeled <strong>Drop Row Fields Here</strong>. That’s adding a slice to the measures. The totals for each measure are now broken up into values by year. If you expand one of the years, you’ll see more detailed slices for the quarters in the selected year.</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Cube-Construction-101_6D94/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/SQLU-SSAS-Week-Cube-Construction-101_6D94/image_thumb.png" border="0" alt="image" width="648" height="92" /></a></p>
<p>Check out the values for your three calculations to confirm that they properly sum up the base measures for overall sales, costs, and order quantities. An MDX calculation is similar to an Excel formula because it uses relative references to determine its current value cell by cell. The difference is that you define the calculation once and you don&#8217;t have to copy it every cell &#8211; it just happens. It looks to see what&#8217;s on rows, what&#8217;s on columns, and also what&#8217;s on the filter (which is the grid area currently labeled <strong>Drop Filter Fields Here</strong>) to come up with the relative reference for each cell in the grid.</p>
<p>Now “dice” the data by dragging Products from the Product dimension to <strong>Drop Column Fields Here</strong>. To make it easier to see the categories, remove some measures. For example, drag <strong>Internet Order Quantity </strong>off the grid, along with the other internet and reseller measure groups so that you’re left with only <strong>Sales Amount</strong>, <strong>Cost</strong>, and <strong>Order Quantity </strong>like this:</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Cube-Construction-101_6D94/SNAGHTML5380b8f.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="SNAGHTML5380b8f" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Cube-Construction-101_6D94/SNAGHTML5380b8f_thumb.png" border="0" alt="SNAGHTML5380b8f" width="697" height="96" /></a></p>
<p>By using hierarchies in the browser, you can drill down to month or to product – but the problem is that category and subcategory keys are shown instead of names. Oops! You’ll need to fix that to improve the cube. That’s why we browse in BIDS before we deliver the cube to users&#8230;so that we can uncover problems like this.</p>
<p><strong>Your Assignment</strong></p>
<p>Try to solve the problem on your own. I’ll reveal the solution in the next post, <a title="SQLU SSAS Week: Cube Enhancements 101" href="http://blog.datainspirations.com/2011/05/15/sqlu-ssas-week-cube-enhancements-101/">Cube Enhancements 101</a>, and as the name implies, I’ll also show you some other enhancements we can make to the cube. Meanwhile, post a comment if you have questions or need help.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.datainspirations.com/2011/05/12/sqlu-ssas-week-cube-construction-101/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>SQLU SSAS Week: Dimension Design 101</title>
		<link>http://blog.datainspirations.com/2011/05/11/sqlu-ssas-week-dimension-design-101-2/</link>
		<comments>http://blog.datainspirations.com/2011/05/11/sqlu-ssas-week-dimension-design-101-2/#comments</comments>
		<pubDate>Wed, 11 May 2011 11:21:18 +0000</pubDate>
		<dc:creator>Stacia Misner</dc:creator>
				<category><![CDATA[Analysis Services]]></category>
		<category><![CDATA[SQL University]]></category>
		<category><![CDATA[SSAS]]></category>

		<guid isPermaLink="false">http://blog.datainspirations.com/2011/05/11/sqlu-ssas-week-dimension-design-101-2/</guid>
		<description><![CDATA[This is the second post for SSAS week at SQL University. If you’re just joining the class, go back to the first post, Why Do I Need a Cube &#38; How Do I Get Started, to get your bearings and get your environment ready, and then join me back here.  Today, I’ll walk you through [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://sqlchicken.com/sql-university" target="_blank"><img class="size-full wp-image-428 alignleft" title="SQL University" src="http://blog.datainspirations.com/wp-content/uploads/2011/05/SQL_University.png" alt="" width="175" height="200" /></a>This is the second post for SSAS week at <a href="http://sqlchicken.com/sql-university/" target="_blank">SQL University</a>. If you’re just joining the class, go back to the first post, <a title="SQLU SSAS Week: Why Do I Need a Cube &amp; How Do I Get Started?" href="http://blog.datainspirations.com/2011/05/11/sqlu-ssas-week-why-do-i-need-a-cube-how-do-i-get-started/" target="_blank">Why Do I Need a Cube &amp; How Do I Get Started</a>, to get your bearings and get your environment ready, and then join me back here.  Today, I’ll walk you through the basic steps of building dimensions. Then, later in the week, I’ll cover cube construction and also discuss various cube enhancements that you can make, security measures to implement, and tools that enable user access to cube data.</p>
<p><strong><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/57c69da7747d_3D0F/SNAGHTML3ea8dd_thumb1_thumb.png"><img style="background-image: none; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="SNAGHTML3ea8dd_thumb[1]_thumb" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/57c69da7747d_3D0F/SNAGHTML3ea8dd_thumb1_thumb_thumb.png" border="0" alt="SNAGHTML3ea8dd_thumb[1]_thumb" width="38" height="31" /></a> Step 0: Analysis Services Project</strong></p>
<p>Before you actually start construction, you need to open Business Intelligence Development Studio—affectionately known as BIDS. You’ll find it in the Microsoft SQL Server 2008 R2 program group on your Start menu. BIDS is a Visual Studio 2008 shell that installs as one of the SQL Server Management Tools when installing SQL Server 2008 R2. You don’t need a Visual Studio license to use it.</p>
<p>To create a new project, open BIDS, click <strong>File-&gt;New-&gt;Project</strong>, and then select the <strong>Analysis Services Project</strong> template in the Business Intelligence Projects. Give the project a name – something creative and inspiring like <strong>My SSAS DB</strong>. Your project will later become a database on the Analysis Server, but it’s nothing like a SQL  Server database. The SSAS database has a lot more files associated with it, and stores data in a completely different way.</p>
<h3><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/57c69da7747d_3D0F/SNAGHTML1f546c9_thumb1_thumb.png"><img style="background-image: none; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="SNAGHTML1f546c9_thumb[1]_thumb" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/57c69da7747d_3D0F/SNAGHTML1f546c9_thumb1_thumb_thumb.png" border="0" alt="SNAGHTML1f546c9_thumb[1]_thumb" width="23" height="20" /></a>Step 1: Data Source</h3>
<p>Data for your cube has to come from somewhere and the Data Source file is the first step in defining where it comes from. It’s quite literally copied from the source and placed into structures that Analysis Services manages. For this course, you’ll use the AdventureWorksDW2008R2 database as described in <a href="http://blog.datainspirations.com/2011/05/09/sqlu-ssas-week-why-do-i-need-a-cube-how-do-i-get-started/" target="_blank">this week’s first lesson</a>. To create a data source, right-click the <strong>Data Sources </strong>folder in the Solution Explorer window (which you can open from the <strong>View</strong> menu if it’s not visible), and select <strong>New Data Source</strong>. Using the wizard, you can step through the process of creating a new data source that defines the data provider, connection string, and authentication method (Windows integrated security or database login) for the source data. Nothing new here—you’ve probably done this sort of thing lots of times using similar interfaces. Bottom line is that you can access any data source with an OLE DB or .NET provider.</p>
<p>The Impersonation Information page of the wizard is something that you&#8217;ve probably not seen before. Here you define the account that Analysis Services uses to connect to the data source. Usually, you select the <strong>Use the service account </strong>option here. The service account is the one that is running the Analysis Services service, either a domain account or a built-in account like NETWORK SERVICE. You need to make sure that this service account has read permissions on AdventureWorksDW2008R2.</p>
<h3><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/57c69da7747d_3D0F/SNAGHTML2014765_thumb1_thumb.png"><img style="background-image: none; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="SNAGHTML2014765_thumb[1]_thumb" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/57c69da7747d_3D0F/SNAGHTML2014765_thumb1_thumb_thumb.png" border="0" alt="SNAGHTML2014765_thumb[1]_thumb" width="18" height="18" /></a> Step 2: Data Source View</h3>
<p>Next, you create a Data Source View (DSV). The DSV lets you focus on selected tables of the source database and make changes as a logical layer without changing the physical structure of your data source, which is helpful if you have only read permissions for that source. For example, you can create logical primary keys and foreign key relationships if they do not exist in your data source. Additionally, you can enhance the data by adding a Named Calculation that uses a valid SQL expression to calculate values in a new logical column of the selected table in the Data Source View. You can also replace a table with a Named Query, which allows you to select specific columns or add derived columns to a selected table just as if you were adding a new view to the underlying data source.</p>
<p>To keep keep this cube relatively small and simple while you learn the basics, you’ll use only a few tables from the source database. Right-click the <strong>Data Source View </strong>folder in the Solution Explorer window, and select <strong>New Data Source View</strong>. Step through the wizard and select following tables: <strong>DimDate</strong>, <strong>DimProduct</strong>, <strong>DimProductSubcategory</strong>, <strong>DimProductCategory</strong>, <strong>FactInternetSales</strong>, and <strong>FactResellerSales</strong>.</p>
<p>All the primary keys and foreign key relationships are detected, so you don’t need to make any adjustments to the DSV to define those required elements. However, to get the Date dimension to work properly, you need to concatenate some columns in the DimDate table to create new derived columns. Right-click on the DimDate label in the diagram and click <strong>New Named Calculation</strong>. For the first calculation, assign a name, like <strong>Quarter</strong>, and use the following expression:</p>
<p><span style="font-family: 'Courier New';">CAST(CalendarYear AS CHAR(4)) + &#8216; Q&#8217; + CAST(CalendarQuarter AS CHAR(1))</span></p>
<p>Add a second calculation named <strong>Month </strong>using the following expression:</p>
<p><span style="font-family: 'Courier New';">CAST(CalendarYear AS CHAR(4)) + &#8216; &#8216; + LEFT(EnglishMonthName, 3)</span></p>
<p>As a final task for the DSV, rename all of the tables to remove the Dim or Fact prefix and to shorten the table names related to product, so that you have <strong>Date</strong>, <strong>Product</strong>, <strong>Subcategory</strong>, <strong>Category</strong>, <strong>InternetSales</strong>, and <strong>ResellerSales</strong>. As you create database objects in subsequent steps, names of objects will be inherited from the tables here in the DSV and it’s usually best to rename everything here to minimize the renaming effort elsewhere. Tip: When working with your own data, the ideal is to rename everything back in the source database, using views if necessary.</p>
<p>When finished, your DSV will be similar to the figure below. Notice the icons for your named calculations Quarter and Month as a visual cue that you’ve enhanced the DSV.</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/57c69da7747d_3D0F/SNAGHTML211132d_thumb2_thumb.png"><img style="background-image: none; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="SNAGHTML211132d_thumb[2]_thumb" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/57c69da7747d_3D0F/SNAGHTML211132d_thumb2_thumb_thumb.png" border="0" alt="SNAGHTML211132d_thumb[2]_thumb" width="407" height="354" /></a></p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/57c69da7747d_3D0F/SNAGHTML23c9eaa_thumb1_thumb.png"><img style="background-image: none; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="SNAGHTML23c9eaa_thumb[1]_thumb" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/57c69da7747d_3D0F/SNAGHTML23c9eaa_thumb1_thumb_thumb.png" border="0" alt="SNAGHTML23c9eaa_thumb[1]_thumb" width="21" height="18" /></a><strong>Step 3: Dimensions</strong></p>
<p>The Data Source and DSV definitions are the foundation for building dimensions and cubes. In this step, you build as many dimensions as you need. You might have one table in a dimension, such as the Date table, or multiple tables (called a snowflake), such as the Product, Subcategory, and Category tables. Most cubes have many more dimensions, but you’ll get the idea of the steps involved by building the two dimensions for this lesson.</p>
<p>When you design a dimension, you select the relevant tables in the DSV, pick the attributes (which you know as table columns) to include in the dimension, define the behavior of these attributes, and relate each attribute to other attributes by setting properties. You use a wizard to do the basic setup of the dimension and then fine-tune the dimension design using a designer interface and the Properties window. There are a lot of properties that you can configure which can seem overwhelming when you’re new to cubes. Frankly, the default values are fine most of the time for simple cubes and need to be changed only when you’re working with more advanced scenarios. I’ll walk you through changing the most important properties in today’s lesson.</p>
<p>To get started, right-click the <strong>Dimensions</strong> folder in Solution Explorer, and click <strong>New Dimension</strong>. For the creation method, select <strong>Use an existing table</strong>, start with the <strong>Date </strong>table as the main table, and change the <strong>Name </strong>column to <strong>FullDateAlternateKey </strong>on the Specify Source Information page of the wizard. On the Select Dimension Attributes page, change <strong>Date Key </strong>to <strong>Date</strong>, and select the checkbox for the following attributes: <strong>CalendarYear</strong>, <strong>Quarter</strong>, and <strong>Month</strong>. Click through the rest of the wizard to wrap it up.</p>
<p>Now it’s time to fine-tune the dimension design in the dimension designer. First, define a hierarchy. Adding a hierarchy not only helps users navigate data more efficiently, but can also improve query performance when a hierarchy contains a natural one-to-many relationship between each level in the hierarchy from top to bottom such as exists between Year, Quarter, and Month. Just drag and drop attributes from the Attributes pane in the dimension designer to the Hierarchies pane. You can also right-click the name of the new hierarchy, select <strong>Rename</strong>, and give it a better name than <strong>Hierarchy</strong>. Maybe something like <strong>Calendar</strong>. The rule is that it must be unique across all hierarchies and attributes in your dimension. When finished, your dimension designer looks like this:</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/57c69da7747d_3D0F/image_thumb_thumb.png"><img style="background-image: none; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image_thumb_thumb" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/57c69da7747d_3D0F/image_thumb_thumb_thumb.png" border="0" alt="image_thumb_thumb" width="244" height="170" /></a></p>
<p>The warning symbol is there because you haven’t defined attribute relationships for the levels of the hierarchy. Attribute relationships are important for performance reasons, so do that next. Click the Attribute Relationships tab in the dimension designer. Drag <strong>Month </strong>on top of <strong>Quarter</strong>, and drag <strong>Quarter </strong>on top of <strong>Calendar Year</strong>. Now you’ve defined the one-to-many relationship from the key attribute (which is the primary key in the table) to each level in the hierarchy (and the little warning symbol is now gone on the Dimension Structure tab – go ahead and take a peek!).</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/57c69da7747d_3D0F/SNAGHTML22b87fe_thumb2_thumb.png"><img style="background-image: none; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="SNAGHTML22b87fe_thumb[2]_thumb" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/57c69da7747d_3D0F/SNAGHTML22b87fe_thumb2_thumb_thumb.png" border="0" alt="SNAGHTML22b87fe_thumb[2]_thumb" width="424" height="30" /></a></p>
<p>Now use what you’ve learned to set up the Product dimension. When you add the dimension using the wizard, set the <strong>Name</strong> column to <strong>EnglishProductName</strong>. You’ll see that the wizard automatically includes Subcategory and Category because it sees the foreign key relationships between the three product-related tables. For attributes, select the following: <strong>Product Key </strong>(which you should rename to <strong>Product</strong>), <strong>Product Subcategory Key</strong> (which you should rename to <strong>Subcategory</strong>), and <strong>Product Category Key</strong> (which you should rename to <strong>Category</strong>).</p>
<p>Create a <strong>Products </strong>hierarchy in this order from top to bottom: <strong>Category</strong>,<strong> Subcategory</strong>,<strong> Product</strong>. If you go to the Attribute Relationships page, you’ll see that the attributes have the correct many-to-one sequence because the table relationships contained the necessary information. With Date, all attributes were in the same table so the designer couldn’t determine the sequencing automatically.</p>
<p>Tip: If you forget to select an attribute when you’re using the wizard, don’t worry. You can drag the attribute from the diagram on the Dimension Structure page to the Attributes pane at any time.</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/57c69da7747d_3D0F/SNAGHTML23f5e22_thumb2_thumb.png"><img style="background-image: none; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="SNAGHTML23f5e22_thumb[2]_thumb" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/57c69da7747d_3D0F/SNAGHTML23f5e22_thumb2_thumb_thumb.png" border="0" alt="SNAGHTML23f5e22_thumb[2]_thumb" width="23" height="23" /></a><strong>Step 4: Deploy and Test</strong></p>
<p>To view a complete dimension as it will appear in a cube, you must deploy your project. Just right-click the project in Solution Explorer, and click <strong>Deploy</strong>. Each Analysis Services project becomes a database on the Analysis Services server when you use the Deploy command in BIDS the first time. In addition, the files that you see in Solution Explorer get copied to the Analysis Services server as database objects and data gets copied from the source tables into these database objects. Tip: If you don’t want to deploy to a local Analysis Services server, right-click the project in Solution Explorer, click <strong>Properties</strong>, and change the <strong>Server </strong>property on the <strong>Deployment </strong>page.</p>
<p>After processing is complete, you can browse each dimension in BIDS using the Browser tab of its respective dimension designer. If you closed the designer, just double-click the dimension in Solution Explorer to re-open it. Each attribute becomes a two-level  hierarchy with the top level containing an All member and the bottom level containing all the unique values found in the corresponding table column. Use the Hierarchy drop-down list to switch between hierarchies in the dimension. Here’s a fragment of the Month attribute hierarchy:</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/57c69da7747d_3D0F/image_thumb4_thumb.png"><img style="background-image: none; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image_thumb[4]_thumb" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/57c69da7747d_3D0F/image_thumb4_thumb_thumb.png" border="0" alt="image_thumb[4]_thumb" width="113" height="146" /></a></p>
<p>Notice anything strange? We’ll fix that in the next step. Whenever you design dimensions, you need to check each attribute hierarchy and each user hierarchy (<strong>Calendar</strong> and <strong>Products</strong> in today’s lesson) to make sure the names of each member appear correctly and in the right sort order. A member is the unique value in a hierarchy – such as <strong>2005 Aug</strong> or <strong>2005 Dec</strong> in the <strong>Month</strong> attribute hierarchy.</p>
<h3>Step 5: Sort Order</h3>
<p>The default sort order for dimension members is by name. You can sort by the key value, assuming the key is correctly defined and will produce the sort order that you want. You can also sort by another attribute in the dimension. To fix the problem above, you start by changing the key value to a composite key based on the year and the month number. Switch to the Dimension Structure tab, click <strong>Month</strong>, and then find the <strong>Key Columns </strong>property in the Properties window. If that window isn’t open, use the <strong>View </strong>menu to open it.</p>
<p>Click in the <strong>Key Columns </strong>box to display the ellipsis button, and then click that button. In the <strong>Key Columns </strong>list, select <strong>Month</strong>, and then click the arrow pointing left to remove the column from the list. Then double-click <strong>CalendarYear </strong>and <strong>MonthNumberOfYear </strong>to add the two columns as a composite key to the list. Click OK to close the dialog box. Now you’ll need to change the <strong>NameColumn </strong>property to <strong>Month</strong>.</p>
<p>Whenever you use a composite key, you must specify a name column. If you’re using only a single column as a key, that column will do double-duty as both key and name column unless you specifically define a name column.</p>
<p>To check the results, you’ll need to redeploy the project. Only the changes you made get deployed so it goes much faster than the initial deployment. Go to the Browser tab and click the <strong>Reconnect </strong>button (the second button on the toolbar) to re-establish communication with the server. The sort order should be correct now for the <strong>Month</strong> attribute hierarchy. The <strong>Month </strong>level of the <strong>Calendar </strong>user hierarchy will also correctly sort.</p>
<p><strong>What’s Next?</strong></p>
<p>Most cubes have a few more dimensions than you’re creating here, but the process is very similar so I won’t walk you through the steps. For extra credit, though, you can try adding in dimensions like Promotion or Sales Territory. As I mentioned earlier, there are a lot of properties to configure for dimensions that allow you to get specific behavior for advanced dimension structures, but the default settings are sufficient when dealing with simple dimensions such as you have in the project now. If you’re really curious, you can check out <a href="http://msdn.microsoft.com/en-us/library/ms174919.aspx" target="_blank">the official list of properties</a>, but most of this won’t likely make more sense until you can put it into context with examples.</p>
<p>In the next post in this series, <a title="SQLU SSAS Week: Cube Construction 101" href="http://blog.datainspirations.com/2011/05/12/sqlu-ssas-week-cube-construction-101/">Cube Construction 101</a>, I’ll show you how to work with the cube wizard and the cube designer. Once you get the cube built, you’ll see how the dimensions work with cubes to facilitate the slice-and-dice capability for which SSAS is famous.</p>
<p>P.S. If you have any trouble with today’s lesson or have questions about dimensions, post a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.datainspirations.com/2011/05/11/sqlu-ssas-week-dimension-design-101-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQLU MDX Week: Location, Location, Location</title>
		<link>http://blog.datainspirations.com/2011/05/11/sqlu-ssas-week-why-do-i-need-a-cube-how-do-i-get-started/</link>
		<comments>http://blog.datainspirations.com/2011/05/11/sqlu-ssas-week-why-do-i-need-a-cube-how-do-i-get-started/#comments</comments>
		<pubDate>Wed, 11 May 2011 11:15:00 +0000</pubDate>
		<dc:creator>Stacia Misner</dc:creator>
				<category><![CDATA[Analysis Services]]></category>
		<category><![CDATA[MDX]]></category>
		<category><![CDATA[SQL University]]></category>

		<guid isPermaLink="false">http://blog.datainspirations.com/?p=427</guid>
		<description><![CDATA[Once again, I am serving as the professor at SQL University during MDX week. MDX stands for MultiDimension eXpression language and we use it to add business logic to cubes in the form of calculations, named sets, and KPIs as well as to configure security and to write reports. I can’t teach you everything you [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://sqlchicken.com/sql-university" target="_blank"><img class="size-full wp-image-428 alignleft" title="SQL University" alt="" src="http://blog.datainspirations.com/wp-content/uploads/2011/05/SQL_University.png" width="175" height="200" /></a>Once again, I am serving as the professor at <a href="http://sqlchicken.com/sql-university/" target="_blank">SQL University</a> during MDX week. MDX stands for MultiDimension eXpression language and we use it to add business logic to cubes in the form of calculations, named sets, and KPIs as well as to configure security and to write reports. I can’t teach you everything you need to know about MDX in just a few blog posts this week, but I can help you get into the right frame of mind to learn MDX, to get some insight into how the language works, and where to learn more to further your studies. </p>
<p>Before you undertake MDX, you should know something about Analysis Services and cubes. Earlier this year, I presented a series of posts as part of SQL&#160; University to introduce you to this topic:</p>
<ul>
<li><a href="http://blog.datainspirations.com/2011/05/11/sqlu-ssas-week-why-do-i-need-a-cube-how-do-i-get-started/" target="_blank">Why Do I Need a Cube and How Do I Get Started?</a></li>
<li><a href="http://blog.datainspirations.com/2011/05/11/sqlu-ssas-week-dimension-design-101-2/" target="_blank">Dimension Design 101</a></li>
<li><a href="http://blog.datainspirations.com/2011/05/12/sqlu-ssas-week-cube-construction-101/" target="_blank">Cube Construction 101</a></li>
<li><a href="http://blog.datainspirations.com/2011/05/15/sqlu-ssas-week-cube-enhancements-101/" target="_blank">Cube Enhancements 101</a></li>
<li><a href="http://blog.datainspirations.com/2011/05/17/sqlu-ssas-week-cube-deployment-101/" target="_blank">Cube Deployment 101</a></li>
</ul>
<p>Before we dive into using MDX later this week, let’s start with perhaps the most fundamental concept that you need to understand – location, location, location.</p>
<h3><strong>Build On What You Know</strong></h3>
<p>You’ve probably used an Excel spreadsheet at some point and are familiar with using cell references to create formulas. For example, in the spreadsheet below, if I want to perform a calculation that includes the sales for the product “Mountain-200 Black, 38” on 1/1/2008, I would use the formula =B2. The letter B stands for the column reference and the number 2 stands for the row reference. It’s a two-dimensional cell reference. </p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Why-Do-I-Need-a-Cube--How_87D9/excel-01.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="excel-01" border="0" alt="excel-01" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Why-Do-I-Need-a-Cube--How_87D9/excel-01_thumb.png" width="603" height="148" /></a></p>
<p>“OK,” you’re thinking. “I got that. Rudimentary Excel. What does that have to do with MDX?” Bear with me a little bit longer and I’ll connect the dots for you. </p>
<p>Now consider that I have two sheets in a workbook with a similar layout. One sheet for 2008 sales and one sheet for 2007 sales. I want to calculate total sales for the same product in January. In this case, I can use the formula =’Sales 2008’!B2 + ‘Sales 2007’!B2. I’ve added a third dimension, the sheet name, to the cell references to tell Excel where to find the data for the calculation.</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Why-Do-I-Need-a-Cube--How_87D9/excel-02.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="excel-02" border="0" alt="excel-02" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Why-Do-I-Need-a-Cube--How_87D9/excel-02_thumb.png" width="757" height="303" /></a></p>
<p>Let’s continue expanding on this concept:</p>
<ul>
<li>For four dimensions, let’s assume that I have a separate workbook for different stores and I want to combine the sales for all stores for the same product and same month across the two years. My formula would now look like this – ‘[Store A.xlsx]Sales 2008’!B2 + ‘[Store B.xlsx]Sales 2008’!B2 + ‘[Store A.xlsx]Sales 2007’!B2 + ‘[Store B.xlsx]Sales 2007’!B2.</li>
<li>For five dimensions, I might use different folders on the same drive to store workbooks by promotion. So now each workbook reference would look something like this: ‘[C:\Top Customer Promotion\Store A.xlsx]Sales 2008’!B2.</li>
<li>Moving on to six dimensions, I can reference workbooks on different drives.</li>
<li>For seven dimensions, I can reference workbooks on different servers.</li>
</ul>
<p>Now I’m going to get a bit silly, but just use your imagination with me for a moment because I can’t really do this. It’s just expanding the concept of location. Here goes… I can reference workbooks on different servers on different floors (eight dimensions), in different buildings (nine dimensions), on different streets (ten dimensions), in different cities (eleven dimensions), in different states (twelve dimensions), in different countries (thirteen dimensions), on different planets (fourteen dimensions) in different universes (fifteen dimensions)! </p>
<p>Okay, I’ve probably gone a bit too far with this example, and technically speaking, I wouldn’t make each of these aspects of a location into a separate dimension from an Analysis Services point of view. But I want you to get the idea that I can use location references in my Excel formulas to be very precise about which data to include in the formula. Excel understands relative references and absolute references. If you don’t tell it otherwise, it’s going to assume that you want a relative reference. That is, use the current cell, column, sheet,&#160; or whatever that happens to be “current” for the cell in which you are typing the formula unless you give it explicit instructions to use a different cell, columns, sheet, or whatever.</p>
<h3>And Now for the Tuple</h3>
<p>Now let’s bring this back to MDX. A key concept in MDX is the tuple. I say tuh-ple because I learned it that way and I’m too old to change. (Think quintuple, sextuple, octuple – et cetera. The letter u is short the way that I learned.) Some people say too-ple, and that’s okay too. The beauty of reading a blog post is that you can read it with whichever pronunciation you prefer and my pronunciation won’t get in your way!</p>
<p>Let’s move our sales data from Excel into an Analysis Services cube. I’ve simplified the product name because the tire size in there seems to distract people. So “Mountain-200 Black, 38” becomes “Mountain-200 Black.” </p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Why-Do-I-Need-a-Cube--How_87D9/tuple-01.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="tuple-01" border="0" alt="tuple-01" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Why-Do-I-Need-a-Cube--How_87D9/tuple-01_thumb.png" width="434" height="284" /></a></p>
<p>To get data from a cube, I need to ask for that data in the form of a tuple. A tuple consists of one member from every dimension. So in my two dimensional representation of cube data above, the tuple to get sales for the Mountain-200 Black product in January would be (Mountain-200 Black, 1/1/2008). </p>
<p>Actually, that’s what I call a pseudo-tuple because it’s not exactly the way we would write it in MDX, but I don’t want you to get distracted by the details. For now, let’s focus on the concepts of a tuple.</p>
<p>Tuples are like coordinates that you learned in geometry. If you have a graph with two dimensions, x and y, you represent a point by using the coordinate (x,y). In geometry, order matters – the x must come before the y. But with tuples, order does NOT matter. We can write your example above as either (Mountain-200 Black, 1/1/2008) or (1/1/2008, Mountain-200 Black) and get the same answer: $66,095.71.</p>
<p>Now in our cube, most dimensions have an All level. And that counts as a cell, too. So we can create a tuple (All Products, All Dates) to get the grand total sales: $4,831,250.71.</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Why-Do-I-Need-a-Cube--How_87D9/tuple-02.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="tuple-02" border="0" alt="tuple-02" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Why-Do-I-Need-a-Cube--How_87D9/tuple-02_thumb.png" width="447" height="285" /></a></p>
<p>If we have two kinds of measures in our sales, Sales Amount and Order Quantity, then that adds a third dimension to our cube. So our tuple changes accordingly to include the new dimension: (Mountain-200 Black, 1/1/2008, Sales Amount).</p>
<p><a href="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Why-Do-I-Need-a-Cube--How_87D9/tuple-03.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="tuple-03" border="0" alt="tuple-03" src="http://blog.datainspirations.com/wp-content/uploads/2010/11/SQLU-SSAS-Week-Why-Do-I-Need-a-Cube--How_87D9/tuple-03_thumb.png" width="541" height="300" /></a></p>
<p>In summary, a tuple is just a location in a cube. We use it to tell Analysis Services where to find the data that we want. Using MDX functions, we can describe sets of tuples that we want to access “as is” or use in formulas. In my next post, I’ll explain how to write simple MDX queries using this concept of tuples.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.datainspirations.com/2011/05/11/sqlu-ssas-week-why-do-i-need-a-cube-how-do-i-get-started/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

