[Mondrian] Compound Slicers

Will Gorman wgorman at pentaho.com
Tue May 20 14:09:37 EDT 2014


Hi folks,

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:

WITH MEMBER [Measures].[Sales Prev Year] AS ([Time].CurrentMember.Lag(1), [Measures].[Sales]
SELECT
{[Product].[All Products].Children} on 0,
{[Measures].[Sales], [Measures].[Sales Prev Year]} on 1
FROM
[My Cube]
WHERE
               CrossJoin({[Region].[NA], [Region].[Europe]}, {[Year].[2014]})

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.

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.

If folks would prefer I can add an internal property to Mondrian which allows folks to disable this behavior.

Here's a link to my initial commit, I still have tests to write:

https://github.com/wgorman/mondrian/commit/39d6ea62c744e7113887a051e3408f7dcb8c03d1

Thanks!

Will
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.pentaho.org/pipermail/mondrian/attachments/20140520/7b92a829/attachment.html 


More information about the Mondrian mailing list