[Mondrian] Course grained measure groups

Julian Hyde julianhyde at gmail.com
Thu Feb 27 21:58:10 EST 2014


On Feb 26, 2014, at 6:04 AM, Matt Campbell <mcampbell at pentaho.com> wrote:

> Julian,
> I'm trying to get a handle on how course grained measure groups work in
> Mondrian 4.  The example in Mondrian in Action describes the scenario
> where measures in one group are at day level, while in another group
> they're at month level.  The schema snippet shows a compound foreign key
> link with the_year and month_of_year, with attribute specified as 'Month'.
> 
> A couple questions:
> 1)  The book says the value at the day level for the course MG should be
> "inherited".  What's the mechanism for that?  How do we avoid incorrect
> rollups?  I was having trouble seeing where in the code that's handled.

I don’t have the book in front of me, and don’t remember the example right now. But I think the general approach for granularity should be the same as for dimensionality — if the measure doesn’t exist at the current attribute’s granularity, force the member to one where the measure exists. I think the effect would be very similar to ValidMeasure.

Now, we’d need to know that [Month] is functionally dependent on [Day]. (Do we have that?) And if [Month] and [Week] are both FD and both have a measure-group, we’d need to disambiguate. (Take whichever has the higher ordinal within the dimension, which is is presumably more granular. Week is in some sense “closer” to Day than Month. Yes this rule is somewhat arbitrary and we may revisit it in future versions.)

> 2)  If the join to the time dimension uses the_year & month_of_year,
> won't measure values be inflated by the number of days?  I.e. since the
> dim table will repeat the month_of_year value for each day in the month.

I think this was a problem with virtual cubes also, when you joined a virtual cube at a non-leaf level. I don’t remember whether we solved it satisfactorily. The ideal solution would be to join to a select-distinct. In pseudo-SQL:

select keys, aggregates
from sales_by_month_by_product
join (select distinct the_year, the_month from time_by_day)
join product using (product_id)
using (the_year, the_month)

I don’t remember whether the mondrian-3 version does anything like that, or whether that is possible to do in mondrian-4.

Julian


More information about the Mondrian mailing list