我试图像这样制作一个MDX查询,似乎几乎工作,除了新措施似乎忽略切片轴/ WHERE
条件,显示客户数量所有国家/地区,而不仅仅是澳大利亚:
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]
我做错了什么?
如果我在SQL中这样做,我会寻找像这样的东西
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
答案 0 :(得分:2)
尝试添加EXISTING
:
With
member [measures].[DistinctCustomersHighSales] as
distinctcount(
filter(EXISTING [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]
范围是MDX中非常重要的概念。只有当您添加 EXISTING
时,引擎才会实现切片器。
成员定义中的初始设置为:
[Customer].[Full Name].Members
在MDX中,集合是静态的。因此,默认情况下,此设置包含所有客户。在添加EXISTING
之前,在形成集合之前,会检查上下文。根据您的多维数据集中的维度用法(关系),它可以过滤属于澳大利亚的客户。因此它有效。