MDX Add Condition to filter for the first 6 month of the year

79 Views Asked by At

I would like to find the top 10 most profitable customers in the first six months of the year 2021 (January through June) sorted by profit in descending order.

The following filter for all criteria except the months:

SELECT [measures].[Profit] ON 0,
TopCount(
    [Customer.FullName].members,
    10,
    [measures].[Profit]
) ON 1
FROM [bike_sales]
WHERE ([OrderDate].[Year].[2021])

I tried extending the WHERE clause with [OrderDate].[Month].[1]:[OrderDate].[Month].[6], however the query results were not correct.

How can the above-mentioned query be adjusted to also filter for the first 6 month of 2021?

1

There are 1 best solutions below

0
On

I ended up combining the month and year:

SELECT [measures].[Profit] ON 0,
TopCount(
    [Customer.FullName].members,
    10,
    [measures].[Profit]
) ON 1
FROM [bike_sales]
WHERE ( [OrderDate.Days].[2021].[1].[1] : [OrderDate.Days].[2021].[6].[30] )