<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Will,<div><br></div><div>This is great work. I don't know whether it complies with the MDX language specification, but it should make it easier to write calculations, and should improve efficiency too.</div><div><br></div><div>I think it should be enabled using a property (enabled by default, but it should be possible to disable it so we can compare the previous behavior).</div><div><br></div><div>We could consider taking this further: analyze the compound slicer at prepare time, and separate out into constant members and expressions. This is like factoring the algebraic expression a.b + a.c into a.(b + c).</div><div><br><div apple-content-edited="true">
<div>Julian</div><br class="Apple-interchange-newline">
</div>
<br><div><div>On May 20, 2014, at 11:09 AM, Will Gorman <<a href="mailto:wgorman@pentaho.com">wgorman@pentaho.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div lang="EN-US" link="blue" vlink="purple" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="WordSection1" style="page: WordSection1;"><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">Hi folks,<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">I’ve been doing some work on compound slicers and figured I’d share, also wanted to know if anyone else is working with them in any way. Mondrian treats compound slicers as an aggregate calculation that gets added to the evaluation context. This was causing problems for us when trying to reference members within the compound slicer within other calculations. For instance:<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">WITH MEMBER [Measures].[Sales Prev Year] AS ([Time].CurrentMember.Lag(1), [Measures].[Sales]<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">SELECT<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; text-indent: 0.5in;">{[Product].[All Products].Children} on 0,<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; text-indent: 0.5in;">{[Measures].[Sales], [Measures].[Sales Prev Year]} on 1<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">FROM<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; text-indent: 0.5in;">[My Cube]<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">WHERE<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"> CrossJoin({[Region].[NA], [Region].[Europe]}, {[Year].[2014]})<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">In this use case, [Sales Prev Year] would return the same value as the current year, due to the aggregate calculation overwriting the context back to Year 2014 vs. 2013.<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">My solution was to use a hybrid approach for the compound slicer. After we evaluate the tuples in the slicer, I removed the members that were repeated. In this case Year 2014 would get removed from the aggregate calculation, and instead act in the way a regular slicer would, becoming part of the slicerEvaluator. This seems to have fixed the problem, and also changed the behavior of CompoundSlicerTest.testRollupAvg(), which now behaves the same for both the set use case and compound slicer use case.<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">If folks would prefer I can add an internal property to Mondrian which allows folks to disable this behavior.<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">Here’s a link to my initial commit, I still have tests to write:<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><a href="https://github.com/wgorman/mondrian/commit/39d6ea62c744e7113887a051e3408f7dcb8c03d1" style="color: purple; text-decoration: underline;">https://github.com/wgorman/mondrian/commit/39d6ea62c744e7113887a051e3408f7dcb8c03d1</a><o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">Thanks!<br><br>Will<o:p></o:p></div></div>_______________________________________________<br>Mondrian mailing list<br><a href="mailto:Mondrian@pentaho.org" style="color: purple; text-decoration: underline;">Mondrian@pentaho.org</a><br><a href="http://lists.pentaho.org/mailman/listinfo/mondrian" style="color: purple; text-decoration: underline;">http://lists.pentaho.org/mailman/listinfo/mondrian</a></div></blockquote></div><br></div></body></html>