in the SSAS AdventureWorks schema, I'm trying to figure out a distinct count of how many distinct customers have made Internet orders greater than $1000.
I attempted to make an MDX query like this, and it seems to almost work, except that new measure seems to ignore the slicer axis / WHERE
condition, showing the count of customers for all countries, not just Australia:
With
member [measures].[DistinctCustomersHighSales] as
distinctcount(
filter([Customer].[Full Name].Members, [Measures].[Internet Sales-Sales Amount] > 1000)
)
SELECT {
[Measures].[Internet Sales-Sales Amount],
[Measures].[DistinctCustomersHighSales]
}
on columns,
([Date].[Calendar Date].[Calendar Year].Members) on rows
FROM [Analysis Services Tutorial]
WHERE [Customer].[Customer Geography].[Country-Region].[Australia]
What am I doing wrong?
If I were doing this in SQL, I would be looking for something like this
SELECT Year(OrderDate) as year,
sum(SalesAmount)
count(case when count(distinct case when SalesAmount > 1000 then dc.customerkey end)
FROM dbo.FactInternetSales fis
join dbo.dimcustomer dc on fis.CustomerKey=dc.CustomerKey
join dbo.DimGeography dg on dc.GeographyKey=dg.GeographyKey
WHERE EnglishCountryRegionName='Australia'
GROUP BY year(OrderDate)
ORDER BY year