Quantcast
Channel: SQL Server Analysis Services forum
Viewing all articles
Browse latest Browse all 14337

MDX Aggregate Question - Incorrect Totals

$
0
0

Pretty new MDX user here using SSAS 2008 R2 - I'm sure I'm missing something obvious, but after two days of staring at this thing I can't find it.

This works fine and returns the result set broken out by month and by location - properly aggregating the two measures.

select {[Measures].[Visits],[Measures].[Outcomes]} on rows,
Crossjoin([Calendar].[Calendar Mon Year].[Jan-2013] : [Calendar].[Calendar Mon Year].[Jan-2013].Lead(11), [Location].[Location Code].&[3]) on columns
from [Location Metrics];

But I want the months and location aggregated into one for a "Current" grouping - a similar set will be constructed for the "Prior" period and another for all locations.  So I understand I'm to use the aggregate() function.  But that's resulting in incorrect totals that don't happen if I don't use aggregate().  

with set CurrentLocation as Crossjoin([Calendar].[Calendar Mon Year].[Jan-2013] : [Calendar].[Calendar Mon Year].[Jan-2013].Lead(11), [Location].[Location Code].&[3])
member [Calendar].[Calendar Hierarchy].CurrentLocationAgg as Aggregate(CurrentLocation)
select  {[Measures].[Visits],[Measures].[Outcomes]} on rows,
{CurrentLocationAgg} on columns
from [Location Metrics];

The first query results in Visits totaling about 3600 over 12 months while the second query results in 51000 over 12 months.  I get the correct total when I specify the measure to aggregate in my calculated member i.e. Aggregate(CurrentLocation, [Measures].[Visits]) but I have to use a dozen different metrics (some of them calculated members) and three sets - the code would become huge and unmanageable if I created a member for each set and measure combination.  Doesn't seem like I should have to do that...

I'd really appreciate a nudge in the right direction here.  Thank you.


Viewing all articles
Browse latest Browse all 14337

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>