TopCount with custom date range

I am using a client tool that allows me to use MDX to specify the axis member of a chart. I need to show on the y axis the top 10 customers in sales order count over the last 12 full months. Because of the way the tool works, all of my logic must be in the axis expression. I cannot use a full MDX query (e.g. with a Where statement) to express this.

TopCount works perfectly if I limit the time period to a specific member, like, limited to orders for June of 2014:

TOPCOUNT([Customer].[Customer].children,10,([Measures].[order Count],[Date].[Month ID].[201406]))

A test query would look like this:

Select [Measures].[Order Count] on 0,
TOPCOUNT([Customer].[Customer].children,10,([Measures].[order Count],[Date].[Month ID].[201406])) on 1
from MyCube

But I need the date range considered in the count to be a specific range, like over the past 12 months, so I was hoping something like this would work:

TOPCOUNT([Customer].[Customer].children,10,([Measures].[order Count],{[Date].[Month ID].[201406]:[Date].[Month ID].[201506]}))

But when I do this I get the message: 

The TOPCOUNT function expects a string or numeric expression for the 3 argument. A tuple set expression was used.

How can I do this?  Actually, the date range I want to use is already defined in a named set.  Ideally, the orders considered in the top 10 are only those orders in the named set, like:

TOPCOUNT([Customer].[Customer].children,10,([Measures].[order Count],[Specific Month Set]))

But when I try using only the named set I get:

The dimension '[Specific Month Set]' was not found in the cube when the string, [Specific Month Set], was parsed.




  • Edited by GenoDave 7 hours 7 minutes ago
July 10th, 2015 8:00pm

I think you'd have to do this in 2 steps. First create a measure that returns the filtered order count, then use that in the topcount

CREATE MEMBER CURRENTCUBE.Measures.[Specific Month Order Count]
AS SUM(
[Specific Month Set], [Measures].[order Count]);

CREATE SET [TopCustomers]
AS TOPCOUNT([Customer].[Customer].children,10,[Measures].[Specific Month Order Count]);

Free Windows Admin Tool Kit Click here and download it now
July 10th, 2015 9:31pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics