I am trying to create an MDX query to calculate the top selling stores for a territory, then subtotal the territory.
I have used the TOPCOUNT function with the GENERATE function to create a SET for the Top Locations, however I am having real trouble trying to sub total each territory.
My MDX is as follows:
WITH SET [TopLocationsPerTerritory] AS
GENERATE(
Except ([Locations].[Territory].MEMBERS, [Locations].[Territory].[All]),
TOPCOUNT(
{[Locations].[Territory].CurrentMember} * Except ([Locations].[Location Hierarchy].[Location].MEMBERS,[Locations].[Location Hierarchy].[Location].[All]),
5,
[Measures].[SLS ($)]
)
)
SELECT {
[Measures].[SLS YTD ($)],
[Measures].[SbD BUD SLS YTD ($)],
[Measures].[SbD BUD v ACT SLS YTD VAR %],
[Measures].[SLS LFL YTD %],
[Measures].[SLS GP YTD ($)],
[Measures].[SbD BUD GP YTD ($)],
[Measures].[SbD BUD v ACT GP YTD VAR %],
[Measures].[SLS LFL GP YTD %],
[Measures].[SLS ($)],
[Measures].[SbD BUD GP ($)],
[Measures].[SbD BUD v ACT SLS VAR %],
[Measures].[SLS LFL %],
[Measures].[SLS GP ($)],
[Measures].[SbD BUD GP ($)],
[Measures].[SbD BUD v ACT GP VAR %],
[Measures].[SLS LFL GP %]
} ON COLUMNS,
(
[TopLocationsPerTerritory]
) on ROWS
And the results are good. However I have tried several ways and cannot get a sub total for each territory. I managed to get a aggregate of the whole dataset however that is not what I need.