<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>peteadshead</title>
	<atom:link href="http://peteadshead.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://peteadshead.wordpress.com</link>
	<description>Things which interest me</description>
	<lastBuildDate>Mon, 19 Nov 2012 17:25:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='peteadshead.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/77ed131f9e3d5a1f826f1dca59df1748?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>peteadshead</title>
		<link>http://peteadshead.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://peteadshead.wordpress.com/osd.xml" title="peteadshead" />
	<atom:link rel='hub' href='http://peteadshead.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Issues with MSAS default members</title>
		<link>http://peteadshead.wordpress.com/2011/08/27/issues-with-msas-default-members/</link>
		<comments>http://peteadshead.wordpress.com/2011/08/27/issues-with-msas-default-members/#comments</comments>
		<pubDate>Sat, 27 Aug 2011 13:18:15 +0000</pubDate>
		<dc:creator>peteads</dc:creator>
				<category><![CDATA[Analysis Services]]></category>
		<category><![CDATA[MDX]]></category>
		<category><![CDATA[MSAS]]></category>
		<category><![CDATA[SSAS]]></category>

		<guid isPermaLink="false">https://peteadshead.wordpress.com/?p=65</guid>
		<description><![CDATA[We recently came across this confusing issue with how default members affect resultsets. If you use default members in your dimension, you may have this issue unknowingly and you should definitely check your reports which go out for validity. Its been a long standing bug-bear of mine that there’s no easy way in Excel of &#8230; <a href="http://peteadshead.wordpress.com/2011/08/27/issues-with-msas-default-members/">Continue reading <span class="meta-nav">&#187;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peteadshead.wordpress.com&#038;blog=26378469&#038;post=65&#038;subd=peteadshead&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>We recently came across this confusing issue with how default members affect resultsets. If you use default members in your dimension, you may have this issue unknowingly and you should definitely check your reports which go out for validity.</p>
<p>Its been a long standing bug-bear of mine that there’s no easy way in Excel of knowing that a default member has been set for an attribute, but this is entirely different and much more serious</p>
<p>Consider a simple cube with the below dimensions. The salient point from the cube design is: </p>
<p>
<ul>
<li>Random Measure – defaults to <b>Daily Sales     <br /></b></li>
<li>Biz Date – defaults to <b>2011-08-25</b></p>
</li>
</ul>
<p><a href="http://peteadshead.files.wordpress.com/2011/08/clip_image0021.jpg"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0;" title="clip_image002" border="0" alt="clip_image002" src="http://peteadshead.files.wordpress.com/2011/08/clip_image002_thumb1.jpg?w=141&#038;h=147" width="141" height="147" /></a></p>
<p>The data in the cube is summarily represented below. The yellow bars represent the default members</p>
<p><a href="http://peteadshead.files.wordpress.com/2011/08/clip_image0041.jpg"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="clip_image004" border="0" alt="clip_image004" src="http://peteadshead.files.wordpress.com/2011/08/clip_image004_thumb1.jpg?w=481&#038;h=153" width="481" height="153" /></a></p>
<p>Now, I want to use this new cube to do Sales reporting by aggregating sales over days. You’ve just done away with the several-hour database queries and are excited about your new cube and the fact that it can do the calculations which used to take hours in a matter of seconds. You’re also excited about the ability for new reports to be generated without the need for IT involvement or testing so business users can ‘self serve’. </p>
<p>Now, I am asked for the total sales across all stores for 24-Aug and 25-Aug.</p>
<p>I do this by setting the below in my Excel</p>
<ul>
<li>Biz Date –<strong> {2011-08-25, 2011-08-24}</strong></li>
<li>Risk Measure – <strong>{ Daily Sales }</strong></li>
<li>Store –<strong> {all}</strong></li>
</ul>
<p><a href="http://peteadshead.files.wordpress.com/2011/08/clip_image006.jpg"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="clip_image006" border="0" alt="clip_image006" src="http://peteadshead.files.wordpress.com/2011/08/clip_image006_thumb.jpg?w=209&#038;h=131" width="209" height="131" /></a></p>
<p>Now, I pull in my Value and see that the answer is <b><u>13</u></b>.<a href="http://peteadshead.files.wordpress.com/2011/08/clip_image008.jpg">     <br /><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="clip_image008" border="0" alt="clip_image008" src="http://peteadshead.files.wordpress.com/2011/08/clip_image008_thumb.jpg?w=515&#038;h=162" width="515" height="162" /></a></p>
<p>I send this off pleased with myself that I’ve managed to answer their query in minutes instead of days. Such a simple query, what could possibly go wrong? I’m then asked to break the sales down by both Date and Store for a more granular report.<a href="http://peteadshead.files.wordpress.com/2011/08/clip_image010.jpg">     <br /><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="clip_image010" border="0" alt="clip_image010" src="http://peteadshead.files.wordpress.com/2011/08/clip_image010_thumb.jpg?w=502&#038;h=214" width="502" height="214" /></a></p>
<p>Now I’m confused &#8211; the total is apparently 21, but according to my initial report, it was 13. This is because 13 is reflective of the default member values only – so in this case it is the value for 25-Aug.</p>
<p>&#160;</p>
<h2>Inconsistent behaviours</h2>
<p>The situation is made worse because the behaviour is inconsistent and depends entirely on how the query is written</p>
<h3>Using Excel and not selecting default members</h3>
<p>If you <b>don’t</b> select the default member, you get the correct sum. Look at the below example</p>
<p>Biz Date – <strong>{2011-08-24, 2011-08-23}     <br /></strong>Risk Measure – <strong>{ Daily Sales }     <br /></strong>Store – <strong>{all}</strong></p>
<p><a href="http://peteadshead.files.wordpress.com/2011/08/clip_image012.jpg"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="clip_image012" border="0" alt="clip_image012" src="http://peteadshead.files.wordpress.com/2011/08/clip_image012_thumb.jpg?w=465&#038;h=125" width="465" height="125" /></a></p>
<h3>Semantical nuances</h3>
<p>How you write your MDX affects the results you get. If you write the below query you get the correct results back.</p>
<p><a href="http://peteadshead.files.wordpress.com/2011/08/clip_image014.jpg"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="clip_image014" border="0" alt="clip_image014" src="http://peteadshead.files.wordpress.com/2011/08/clip_image014_thumb.jpg?w=461&#038;h=318" width="461" height="318" /></a></p>
<p>Excel, unfortunately, generates nested select statements. The actual query generated is below. Its as if the red box is ignored.</p>
<p><a href="http://peteadshead.files.wordpress.com/2011/08/clip_image016.jpg"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="clip_image016" border="0" alt="clip_image016" src="http://peteadshead.files.wordpress.com/2011/08/clip_image016_thumb.jpg?w=449&#038;h=343" width="449" height="343" /></a></p>
<p>A different query, but still keeping with a sub-select similarly ignores the red box.</p>
<p><a href="http://peteadshead.files.wordpress.com/2011/08/clip_image018.jpg"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="clip_image018" border="0" alt="clip_image018" src="http://peteadshead.files.wordpress.com/2011/08/clip_image018_thumb.jpg?w=464&#038;h=326" width="464" height="326" /></a></p>
<h2>Summary</h2>
<p>This issue will only affect you if you set default members in your dimensions and write queries using sub-selects. If you leave everything defaulted to the ‘all’ member, you can continue blissfully unaware. It may sound obvious, but if you are using defaulted members in your dimensions, make sure you test your output thoroughly.</p>
<p>This is going to be documented on the Microsoft Knowledgebase soon as a KB article, but that’s akin to a health warning on medication.</p>
<h2>Acknowledgements</h2>
<p>Sanjay Nayyar and Christian Bracchi from <a href="http://www.imgroup.com/">IMGROUP</a> for helping identify this issue</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/peteadshead.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/peteadshead.wordpress.com/65/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peteadshead.wordpress.com&#038;blog=26378469&#038;post=65&#038;subd=peteadshead&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://peteadshead.wordpress.com/2011/08/27/issues-with-msas-default-members/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/b30b7f0b23c56e8d2798a829d48db9dc?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">peteadshead</media:title>
		</media:content>

		<media:content url="http://peteadshead.files.wordpress.com/2011/08/clip_image002_thumb1.jpg" medium="image">
			<media:title type="html">clip_image002</media:title>
		</media:content>

		<media:content url="http://peteadshead.files.wordpress.com/2011/08/clip_image004_thumb1.jpg" medium="image">
			<media:title type="html">clip_image004</media:title>
		</media:content>

		<media:content url="http://peteadshead.files.wordpress.com/2011/08/clip_image006_thumb.jpg" medium="image">
			<media:title type="html">clip_image006</media:title>
		</media:content>

		<media:content url="http://peteadshead.files.wordpress.com/2011/08/clip_image008_thumb.jpg" medium="image">
			<media:title type="html">clip_image008</media:title>
		</media:content>

		<media:content url="http://peteadshead.files.wordpress.com/2011/08/clip_image010_thumb.jpg" medium="image">
			<media:title type="html">clip_image010</media:title>
		</media:content>

		<media:content url="http://peteadshead.files.wordpress.com/2011/08/clip_image012_thumb.jpg" medium="image">
			<media:title type="html">clip_image012</media:title>
		</media:content>

		<media:content url="http://peteadshead.files.wordpress.com/2011/08/clip_image014_thumb.jpg" medium="image">
			<media:title type="html">clip_image014</media:title>
		</media:content>

		<media:content url="http://peteadshead.files.wordpress.com/2011/08/clip_image016_thumb.jpg" medium="image">
			<media:title type="html">clip_image016</media:title>
		</media:content>

		<media:content url="http://peteadshead.files.wordpress.com/2011/08/clip_image018_thumb.jpg" medium="image">
			<media:title type="html">clip_image018</media:title>
		</media:content>
	</item>
		<item>
		<title>Using AMO to administer MSAS cubes</title>
		<link>http://peteadshead.wordpress.com/2011/08/20/using-amo-to-administer-msas-cubes/</link>
		<comments>http://peteadshead.wordpress.com/2011/08/20/using-amo-to-administer-msas-cubes/#comments</comments>
		<pubDate>Sat, 20 Aug 2011 01:09:10 +0000</pubDate>
		<dc:creator>peteads</dc:creator>
				<category><![CDATA[AMO]]></category>
		<category><![CDATA[Analysis Services]]></category>
		<category><![CDATA[Analysis Services Management Objects]]></category>
		<category><![CDATA[MSAS]]></category>
		<category><![CDATA[processAdd]]></category>
		<category><![CDATA[processUpdate]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SSAS]]></category>
		<category><![CDATA[XMLA]]></category>

		<guid isPermaLink="false">https://peteadshead.wordpress.com/?p=28</guid>
		<description><![CDATA[I’ve recently been looking into using AMO to automate common configuration tasks to our MSAS cube infrastructure. In our production environment, we have multiple copies of cubes and multiple servers on which they’re stored so minimizing manual tasks was a must. Sure, all of what is being described below can be done using a combination &#8230; <a href="http://peteadshead.wordpress.com/2011/08/20/using-amo-to-administer-msas-cubes/">Continue reading <span class="meta-nav">&#187;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peteadshead.wordpress.com&#038;blog=26378469&#038;post=28&#038;subd=peteadshead&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I’ve recently been looking into using AMO to automate common configuration tasks to our MSAS cube infrastructure. In our production environment, we have multiple copies of cubes and multiple servers on which they’re stored so minimizing manual tasks was a must. Sure, all of what is being described below can be done using a combination of BIDS and SSMS, but we have our own reasons for not following them in a live environment just as you will have yours. Therefore, we came up with the idea for a tool which could do the heavy lifting for us. AMO seemed like the obvious choice at first, until I started playing with it and realized how incredibly unintuitive it is until you really know how to use it.</p>
<p>While writing the tool, I realized as I’m sure many of you reading this have, that there is little to no documentation on using AMO and its usage is a voyage of discovery. Hindsight being a wonderful tool, it was usually easier to use BIDS and SSMS to do the task, capture the XMLA using profiler and reverse engineer the AMO code from the XMLA by mapping XMLA tags to properties in AMO.</p>
<p>With AMO, to do basic things such as connect to a cube or processAdd a dimension is relatively simple. If, however, you want to do something more complex, you’re on your own and you have a world of unintelligible error messages ahead of you.</p>
<h2>Getting started with AMO</h2>
<p>Here is some basic code to get you started using AMO. Note that error trapping has been removed for readability.</p>
<p>Tip: In your programs, I suggest you use AMO as a reference so when you come across reserved words such as ‘Action’, you don’t have any confusion with Microsoft.AnalysisServices.Action and System.Action. This also makes the code more readable. In C#, this is done as below.</p>
<table width="402" border="1" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td valign="top" width="400">
<!-- code formatted by http://manoli.net/csharpformat/ --></p>
<pre class="brush: csharp;">
using AMO = Microsoft.AnalysisServices;

AMO.Server server = new AMO.Server();
server.Connect(&lt;server&gt;);

<span class="rem">// Pick your poison:</span>
<span class="rem">// "FindByName" uses 'Name' as the method description implies</span>
<span class="rem">// "Find" uses 'ID' – which ID you need to know in advance</span>
AMO.Database database = server.Databases.FindByName(<span class="str">"&lt;database Name&gt;"</span>);
AMO.Database databaseByID   = server.Databases.Find(<span class="str">"&lt;database ID&gt;"</span>);

AMO.Cube cube = database.Cubes.FindByName(<span class="str">"&lt;cube name&gt;"</span>);
</pre>
</td>
</tr>
</tbody>
</table>
<p>If you are using AMO to configure / process a cube, it’s a reasonably safe assumption that you’re familiar with BIDS and SSMS. If you’re not, I suggest you get familiar with them before attempting to use AMO as the AMO Object Model is very similar to both BIDS and SSMS. Thus, for example to access a dimension, you use AMO.Database to access it</p>
<table width="400" border="0" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td valign="top" width="400">
<!-- code formatted by http://manoli.net/csharpformat/ --></p>
<pre class="csharpcode">
<code>
AMO.Dimension dim =  database.Dimensions.FindByName(<span class="str">"&lt;dimension Name&gt;"</span>);</pre>
<p></code>
</td>
</tr>
</tbody>
</table>
<p>If you script out the Adventure Works database, you will see that the Dimension ID and Dimension NAME fields are the same across all Dimensions. This is important because it masks an annoying feature of AMO/SSAS. Specifically, what happens if you rename a Dimension, or if you add it to the Cube and rename it afterwards. It may sound obvious, but the key to successful AMO usage is to know what you need and use the XMLA to make sure you’re asking for what you think you’re asking for</p>
<h3>Dimension XMLA</h3>
<p><a href="http://peteadshead.files.wordpress.com/2011/08/clip_image002.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0;" title="clip_image002" src="http://peteadshead.files.wordpress.com/2011/08/clip_image002_thumb.jpg?w=244&#038;h=99" alt="clip_image002" width="244" height="99" border="0" /></a></p>
<h3>Cube Dimension XMLA</h3>
<p><a href="http://peteadshead.files.wordpress.com/2011/08/clip_image004.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0;" title="clip_image004" src="http://peteadshead.files.wordpress.com/2011/08/clip_image004_thumb.jpg?w=244&#038;h=88" alt="clip_image004" width="244" height="88" border="0" /></a></p>
<p>This may not represent the reality of your organisation as the above have never been renamed and are hence identical. Your dimensions may have been renamed several times. If that is the case, the above ID/Name combinations will be inconsistent</p>
<p>For example,</p>
<p>- Create a Named Query called <strong>NewNameQuery1 </strong>in the DataSourceView<br />
- Create a New Dimension called <strong>NewDimension1 </strong>referencing<strong> NewNameQuery1<br />
</strong></p>
<p>- Save the Dimension</p>
<p>- Rename <strong>NewDimension1</strong> to <strong>NewDimension2<br />
</strong><span style="text-decoration:underline;">impact:</span><strong> </strong><em>ID will be </em><strong>NewDimension1 </strong><em>forever, Name is now </em><strong>NewDimension2</strong></p>
<p>- Add a CubeDimension referencing <strong>NewDimension2<br />
</strong><span style="text-decoration:underline;">impact:</span><strong> </strong><em>CubeDimension.ID will be </em><strong>NewDimension2 </strong><em>forever, CubeDimension.Name is now </em><strong>NewDimension2</strong></p>
<p>- Rename CubeDimension.Name to <strong>NewCubeDimension3</strong><em><br />
</em><span style="text-decoration:underline;">impact:</span><strong> </strong><em>CubeDimension.ID is still </em><strong>NewDimension2</strong><em>, CubeDimension.Name is now </em><strong>NewCubeDimension3</strong></p>
<p>If you look in the Cube Design Properties for the new Cube Dimension, you will see the below</p>
<h3>BIDS representation</h3>
<p><a href="http://peteadshead.files.wordpress.com/2011/08/clip_image005.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0;" title="clip_image005" src="http://peteadshead.files.wordpress.com/2011/08/clip_image005_thumb.png?w=244&#038;h=145" alt="clip_image005" width="244" height="145" border="0" /></a></p>
<h3>XMLA representation</h3>
<p><a href="http://peteadshead.files.wordpress.com/2011/08/clip_image007.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0;" title="clip_image007" src="http://peteadshead.files.wordpress.com/2011/08/clip_image007_thumb.jpg?w=244&#038;h=97" alt="clip_image007" width="244" height="97" border="0" /></a></p>
<p>Now, if you want to use AMO to reference the above Dimension/CubeDimension, you must use one of the following</p>
<table width="400" border="0" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td valign="top" width="400">
<code><br />
<!-- code formatted by http://manoli.net/csharpformat/ --></p>
<pre class="csharpcode">
<span class="rem">/*</span>
<span class="rem"> * The below are all logically equivalent [ cubeDimByID.Equals(cubeDimByName) == true ]</span>
<span class="rem"> *  - FIND       uses CubeDimensionID</span>
<span class="rem"> *  - FINDBYNAME uses CubeDimensionNAME</span>
<span class="rem"> * </span>
<span class="rem"> */</span>
AMO.CubeDimension cubeDimByID   = cube.Dimensions.Find(<span class="str">"NewDimension2"</span>);
AMO.CubeDimension cubeDimByName = cube.Dimensions.FindByName(<span class="str">"NewCubeDimension3"</span>);

Boolean truefalse1 = cubeDimByID.Equals(cubeDimByName);

<span class="rem">/*</span>
<span class="rem"> * The below are all logically equivalent [ dimByID.Equals(dimByCubeDim) &amp;&amp; dimByCubeDim.Equals(dimByName) &amp;&amp; dimByName.Equals(dimByID) == true ]</span>
<span class="rem"> *  - FIND       uses DimensionID whether found through linkage of CubeDimension or directly through knowledge of the DimensionID</span>
<span class="rem"> *  - FINDBYNAME uses DimensionNAME</span>
<span class="rem"> */</span>
AMO.Dimension dimByID       = database.Dimensions.Find(<span class="str">"NewDimension1"</span>);
AMO.Dimension dimByCubeDim  = database.Dimensions.Find(cubeDimByID.DimensionID);
AMO.Dimension dimByName     = database.Dimensions.FindByName(<span class="str">"NewDimension2"</span>);

Boolean truefalse2 = dimByID.Equals(dimByCubeDim) &amp;&amp; dimByCubeDim.Equals(dimByName) &amp;&amp; dimByName.Equals(dimByID);
</pre>
<p></code>
</td>
</tr>
</tbody>
</table>
<p>When you are using AMO, you will need to be clear whether you need the AMO.<strong>MeasureGroup</strong>Dimension.ID, the AMO.<strong>Cube</strong>Dimension.ID or the AMO.Dimension.ID. The best rule of thumb I have found is to assume it is the AMO.Dimension.ID as a first assumption.</p>
<h2>Gotchas with AMO</h2>
<p>There are several gotchas to be aware of when using AMO, the two main of which are that error messages are almost non-existent, the more interesting though is that you can get a success return message but no changes actually applied. If you are lucky enough to get an error message, there’s usually no guarantee that it relates to what you were trying to do in the first place and the AMO.AmoException.InnerException is cryptic.</p>
<p>Let’s use some code to look at real examples.</p>
<h5>Gotcha #1: not using .validate method</h5>
<p>Calling .Validate method prior to calling .Update is strongly recommended, this usually gives more usable information on which to act. For example, consider the below code</p>
<p><a href="http://peteadshead.files.wordpress.com/2011/08/clip_image009.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0;" title="Validate needs to be called" src="http://peteadshead.files.wordpress.com/2011/08/clip_image009_thumb.jpg?w=300&#038;h=153" alt="clip_image009" width="300" height="153" border="0" /></a></p>
<p>Having received the popup and no errors, my Dimension <em>Pete Dimension Name</em> should now exist. However, looking in SSMS - its not there. Note: NewDimension2 is the dimension I created earlier for this blogpost.</p>
<p><a href="http://peteadshead.files.wordpress.com/2011/08/clip_image011.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0;" title="clip_image011" src="http://peteadshead.files.wordpress.com/2011/08/clip_image011_thumb.jpg?w=191&#038;h=105" alt="clip_image011" width="191" height="105" border="0" /></a></p>
<p>This is one frustrating feature of AMO and it will definitely bite you many times. Now consider the slightly modified code below.</p>
<p><a href="http://peteadshead.files.wordpress.com/2011/08/clip_image013.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0;" title="clip_image013" src="http://peteadshead.files.wordpress.com/2011/08/clip_image013_thumb.jpg?w=244&#038;h=171" alt="clip_image013" width="244" height="171" border="0" /></a></p>
<p>Now it makes sense why I don’t see my new Dimension above when just calling Update. I have to fix the problems described in the ValidationErrorCollection before it will appear.</p>
<h3>Gotcha #2: not calling .update method in the correct order</h3>
<p><a href="http://peteadshead.files.wordpress.com/2011/08/clip_image015.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0;" title="clip_image015" src="http://peteadshead.files.wordpress.com/2011/08/clip_image015_thumb.jpg?w=244&#038;h=150" alt="clip_image015" width="244" height="150" border="0" /></a></p>
<p>This code executes successfully, I get no errors and so I think it has worked. <strong>It hasn’t.<br />
</strong><a href="http://peteadshead.files.wordpress.com/2011/08/clip_image017.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0;" title="clip_image017" src="http://peteadshead.files.wordpress.com/2011/08/clip_image017_thumb.jpg?w=208&#038;h=131" alt="clip_image017" width="208" height="131" border="0" /></a></p>
<p>In order to get it working, FIRST I must call update on the Dimension itself as that has changed.<br />
<a href="http://peteadshead.files.wordpress.com/2011/08/clip_image019.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0;" title="clip_image019" src="http://peteadshead.files.wordpress.com/2011/08/clip_image019_thumb.jpg?w=244&#038;h=23" alt="clip_image019" width="244" height="23" border="0" /></a></p>
<p>Now it works successfully.<br />
<a href="http://peteadshead.files.wordpress.com/2011/08/clip_image021.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="clip_image021" src="http://peteadshead.files.wordpress.com/2011/08/clip_image021_thumb.jpg?w=209&#038;h=128" alt="clip_image021" width="209" height="128" border="0" /></a></p>
<p>The revised code is below. <em>Note: I should have called validate before the AMO.Dimension.Update() too but have omitted it here in the interests of space saving</em></p>
<table width="400" border="0" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td valign="top" width="400">
<code><br />
<!-- code formatted by http://manoli.net/csharpformat/ --></p>
<pre class="csharpcode">
AMO.Dimension d2 = database.Dimensions.FindByName(<span class="str">"Dim Time"</span>);

d2.Attributes[<span class="str">"Day Number Of Week"</span>].Name = <span class="str">"Day Number Of Week renamed"</span>;
d2.Update();

 <span class="preproc">#region</span> hide-me:
 AMO.ValidationErrorCollection returnedErrors = <span class="kwrd">new</span> AMO.ValidationErrorCollection();

 <span class="rem">// First validate the operation</span>
 database.Validate(returnedErrors, <span class="kwrd">true</span>);
 <span class="kwrd">if</span> (returnedErrors.Count &gt; 0)
 {
     <span class="preproc">#region</span> Error Collection
        String s = <span class="str">""</span>;
        <span class="kwrd">int</span> i = 0;
        <span class="kwrd">foreach</span> (AMO.ValidationError err <span class="kwrd">in</span> returnedErrors)
{
            s = String.Format(<span class="str">"{0}{1}:{2}\n"</span>, s, ++i, err.FullErrorText);
}
        MessageBox.Show(s);
        <span class="preproc">#endregion</span>
        <span class="kwrd">throw</span> <span class="kwrd">new</span> CustomException(returnedErrors);
}
<span class="preproc">#endregion</span>

database.Update();
</pre>
<p></code>
</td>
</tr>
</tbody>
</table>
<p>You must call .Update on all affected objects in the correct order. The order is defined by inheritance…so Children come first, and then Parents. So, in the above example, AMO.Dimension is a child of AMO.Database. Hence the order is to call AMO.Dimension first, and AMO.Database second. If I had included a change to an AMO.DimensionPermission, this is a CHILD of AMO.Dimension and hence the order would be AMO.DimensionPermission, AMO.Dimension, AMO.Database</p>
<h2>Summary</h2>
<p>AMO is very powerful and useful for administration tasks, but you need to be extremely careful what you write and test it thoroughly.</p>
<p>Once you have got AMO working, what can be done is almost limitless. For example, you can script common tasks – such as</p>
<p>- ProcessUpdate all dimensions<br />
- Hide / Unhide Dimension members<br />
- Change drill through members<br />
- Amend the cube calculation script<br />
- Alter Dimension-Data security in a role.</p>
<p>In the book <a href="http://www.amazon.com/Microsoft-Server-Analysis-Services-Unleashed/dp/0672330016/ref=sr_1_10?ie=UTF8&amp;qid=1313675585&amp;sr=8-10">Microsoft SQL Server 2008 Analysis Services Unleashed</a>, Chapter 34 is a great chapter on using AMO with some real code examples to get you started. Combined with the above, hopefully you’ll be able to create many useful tools using AMO. I’d be very interested to hear how you’ve used AMO to enhance cube administration.</p>
<p>Update: I recently found <a href="http://bennyaustin.wordpress.com/2011/07/06/ssas-amo-coding-tips/">this</a> website too which is another good source of AMO tips.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/peteadshead.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/peteadshead.wordpress.com/28/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peteadshead.wordpress.com&#038;blog=26378469&#038;post=28&#038;subd=peteadshead&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://peteadshead.wordpress.com/2011/08/20/using-amo-to-administer-msas-cubes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/b30b7f0b23c56e8d2798a829d48db9dc?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">peteadshead</media:title>
		</media:content>

		<media:content url="http://peteadshead.files.wordpress.com/2011/08/clip_image002_thumb.jpg" medium="image">
			<media:title type="html">clip_image002</media:title>
		</media:content>

		<media:content url="http://peteadshead.files.wordpress.com/2011/08/clip_image004_thumb.jpg" medium="image">
			<media:title type="html">clip_image004</media:title>
		</media:content>

		<media:content url="http://peteadshead.files.wordpress.com/2011/08/clip_image005_thumb.png" medium="image">
			<media:title type="html">clip_image005</media:title>
		</media:content>

		<media:content url="http://peteadshead.files.wordpress.com/2011/08/clip_image007_thumb.jpg" medium="image">
			<media:title type="html">clip_image007</media:title>
		</media:content>

		<media:content url="http://peteadshead.files.wordpress.com/2011/08/clip_image009_thumb.jpg" medium="image">
			<media:title type="html">Validate needs to be called</media:title>
		</media:content>

		<media:content url="http://peteadshead.files.wordpress.com/2011/08/clip_image011_thumb.jpg" medium="image">
			<media:title type="html">clip_image011</media:title>
		</media:content>

		<media:content url="http://peteadshead.files.wordpress.com/2011/08/clip_image013_thumb.jpg" medium="image">
			<media:title type="html">clip_image013</media:title>
		</media:content>

		<media:content url="http://peteadshead.files.wordpress.com/2011/08/clip_image015_thumb.jpg" medium="image">
			<media:title type="html">clip_image015</media:title>
		</media:content>

		<media:content url="http://peteadshead.files.wordpress.com/2011/08/clip_image017_thumb.jpg" medium="image">
			<media:title type="html">clip_image017</media:title>
		</media:content>

		<media:content url="http://peteadshead.files.wordpress.com/2011/08/clip_image019_thumb.jpg" medium="image">
			<media:title type="html">clip_image019</media:title>
		</media:content>

		<media:content url="http://peteadshead.files.wordpress.com/2011/08/clip_image021_thumb.jpg" medium="image">
			<media:title type="html">clip_image021</media:title>
		</media:content>
	</item>
	</channel>
</rss>