<div><br></div>Subselects on mdx? Spooky!! <span></span><br><br>On Friday, October 26, 2012, Paul Stoellberger  wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><div>On the general issue here is what SSAS / Analyzer do:</div><div><br></div><div>1) SSAS</div>Ok after some more reading I finally understand the concept of sub-selects in SSAS better.<div>
It seems like by using the sub-select they overcome the problem of having visual totals and selecting only specific members in a very elegant way.</div><div><br></div><div>This is a good explanation of it: <a href="http://sqlblog.com/blogs/mosha/archive/2006/11/12/slicer-and-axis-interaction-in-mdx-part-2-implicit-exists.aspx" target="_blank">http://sqlblog.com/blogs/mosha/archive/2006/11/12/slicer-and-axis-interaction-in-mdx-part-2-implicit-exists.aspx</a></div>
<div><br></div><div>So for example you can do a query like:</div><div>SELECT</div><div>    [Measures].[Unit Sales] ON COLUMNS,</div><div>    { [Product].[Product Family].Members, [Product].[Product Department].Members } ON ROWS</div>
<div>   FROM</div><div>      ( SELECT [Product].[Drink].[Dairy] ON COLUMNS FROM [Sales] )</div><div><br></div><div>This will not only take care of the VisualTotals but also restrict the space to Product.Drink.Dairy.</div>
<div>An equivalent of todays mondrian mdx would be:</div><div><br></div><div><div>SELECT</div><div>    [Measures].[Unit Sales] ON COLUMNS,</div><div>    VisualTotals(Hierarchize(Exists(</div><div><span style="white-space:pre-wrap">        </span>{ [Product].[Product Family].Members, [Product].[Product Department].Members }</div>
<div><span style="white-space:pre-wrap">        </span>, { [Product].[Drink].[Dairy] }</div><div>     ))) ON ROWS</div><div>   FROM</div><div><span style="white-space:pre-wrap">        </span>[Sales]</div></div><div><br></div><div><br>
</div><div>Is there any plan for allowing sub selects like that in mondrian?</div><div>SSAS seems to support it since SSAS 2005 at least.</div><div><br></div><div>2) Analyzer</div><div>It seems like Benny (Analyzer) is creating new calculated members within the levels to create visual totals.</div>
<div>So for each parent member selected in the query there is a separate Aggregate() function. As you add levels they get more and more, so you can easily end up with that kind of mdx: <a href="http://pastebin.com/4BH6hy2n" target="_blank">http://pastebin.com/4BH6hy2n</a> (quite verbose and ugly)</div>
<div><br></div><div>This is practically the same thing as VisualTotals() is using internally to calculate the totals, its just hidden in a nice MDX function.</div><div>Thats why I like it so much, it fits perfectly my needs.</div>
<div><br></div><div><br></div><div>Do you have some other input on visual totals?</div><div>This is one of the most requested features and before I start doing it all manually I would much rather prefer an MDX solution.</div>
<div><br></div><div>-Paul</div><div><br></div><div><br><div><div>On Oct 26, 2012, at 2:10 AM, Paul Stoellberger wrote:</div><br><blockquote type="cite"><div style="word-wrap:break-word">Since I&#39;m trying to fix VisualTotals() I would like to know what the desired behaviour is. Especially regarding the order in the set.<div>
<br></div><div>MSDN says:</div><div><span style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:left;font-style:normal;display:inline!important;font-weight:normal;float:none;line-height:normal;text-transform:none;font-size:13px;white-space:normal;font-family:&#39;Segoe UI&#39;,Verdana,Arial;word-spacing:0px">Totals are visually totaled for sets ordered in hierarchy order. If the order of members in sets breaks the hierarchy, results are not visual totals. For example, VisualTotals (USA, WA, CA, Seattle) does not return WA as Seattle, but rather returns the values for WA, CA, and Seattle, then totals these values as the visual total for USA, counting the sales for Seattle twice.</span></div>
<div><span style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:left;font-style:normal;display:inline!important;font-weight:normal;float:none;line-height:normal;text-transform:none;font-size:13px;white-space:normal;font-family:&#39;Segoe UI&#39;,Verdana,Arial;word-spacing:0px"><br>
</span></div><div><span style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:left;font-style:normal;display:inline!important;font-weight:normal;float:none;line-height:normal;text-transform:none;font-size:13px;white-space:normal;font-family:&#39;Segoe UI&#39;,Verdana,Arial;word-spacing:0px">So this means that VisualTotals() will only work if they are ordered. I disagree but I can live with that.</span></div>
<div><span style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:left;font-style:normal;display:inline!important;font-weight:normal;float:none;line-height:normal;text-transform:none;font-size:13px;white-space:normal;font-family:&#39;Segoe UI&#39;,Verdana,Arial;word-spacing:0px">What I don&#39;t understand is what happens when I execute it on a set thats Hierarchize(&lt;set&gt;, POST). </span></div>
<div><span style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:left;font-style:normal;display:inline!important;font-weight:normal;float:none;line-height:normal;text-transform:none;font-size:13px;white-space:normal;font-family:&#39;Segoe UI&#39;,Verdana,Arial;word-spacing:0px"><span style="font-family:Helvetica;font-size:medium"><br>
</span></span></div><div><span style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:left;font-style:normal;display:inline!important;font-weight:normal;float:none;line-height:normal;text-transform:none;font-size:13px;white-space:normal;font-family:&#39;Segoe UI&#39;,Verdana,Arial;word-spacing:0px"><span style="font-family:Helvetica;font-size:medium">Technically the set is ordered hierarchically, just in the reverted order.</span></span></div>
<div><span style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:left;font-style:normal;display:inline!important;font-weight:normal;float:none;line-height:normal;text-transform:none;font-size:13px;white-space:normal;font-family:&#39;Segoe UI&#39;,Verdana,Arial;word-spacing:0px"><span style="font-family:Helvetica;font-size:medium">Should VisualTotals work than as expected, summing up the preceding descendants?</span></span></div>
<div><span style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:left;font-style:normal;display:inline!important;font-weight:normal;float:none;line-height:normal;text-transform:none;font-size:13px;white-space:normal;font-family:&#39;Segoe UI&#39;,Verdana,Arial;word-spacing:0px"><span style="font-family:Helvetica;font-size:medium">If so, can we find out using the Exp[] if a hierarchize was applied and if so in which direction?</span></span></div>
<div><span style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:left;font-style:normal;display:inline!important;font-weight:normal;float:none;line-height:normal;text-transform:none;font-size:13px;white-space:normal;font-family:&#39;Segoe UI&#39;,Verdana,Arial;word-spacing:0px"><span style="font-family:Helvetica;font-size:medium"><br>
</span></span></div><div style="text-align:left">I&#39;m a bit surprised that they have designed it that way.</div><div style="text-align:left">This makes this nice little feature less usable than anticipated.</div><div style="text-align:left">
<br></div><div style="text-align:left">I assume you want to keep it close to SSAS and stick to the same behaviour?</div><div style="text-align:left"><br></div><div style="text-align:left">-Paul</div><div style="text-align:left">
<br></div></div></blockquote></div><br></div></div></blockquote>