We have a Date dimension composed of two hierarchies:
Calendar: Year, Quarter, Month, Day in Month
Date: Day
We are generating MDX from a user interface. We want to be able to let users aggregate between any arbitrary date range (i.e. the Day level in the Date hierarchy). They can also aggregate by either all, year, quarter or month.
We are using a query similar to below. In this case the user has chosen to view the all total. If they put in date range between 2004-2005 we want to only display the totals between those date ranges, but what happens is it returns the all totals. We think we understand why this is happening.
What we want is the best approach to aggregating the totals efficiently between any two date ranges without having to manually do a SUM down at the lowest level of our Calendar or Date hierarchy. Obviously it would be more efficient if the user asks for the totals for 6 months and 3 days of 2005, to just sum the precomputed values we have for the Jan-June, then add the values for the 3 days. Is there a function to do this automatically in MDX?
SELECT { [Measures].[Record Count] } ON COLUMNS, { [Date].[Calendar].[All] } ON ROWS FROM [Cube] WHERE ( [Date].[Day].&[2004-01-01T00:00:00]:[Date].[Day].&[2005-01-01T00:00:00] )