MDX查询Count()在我们将[Account]。[Account Number]。& [1]放在WHERE子句中时返回null

时间:2011-09-21 17:07:47

标签: mdx

在我们的Adventure Works多维数据集中,如果我们运行以下查询,我们将返回两个空单元格,并且只会发生在帐号中的某些成员。有谁知道为什么?

将返回两个具有空值的单元格的查询:

WITH MEMBER count1 AS 'Count(Crossjoin([Measures].[Amount], [Date].[Calendar Year].[Calendar Year]))'
MEMBER count2 AS 'Count(DrilldownLevel([Department].[Departments]))'

SELECT  {count1, count2} ON 0 FROM [Adventure Works]
WHERE [Account].[Account Number].&[1]

将返回两个正确数字的单元格的查询:

WITH MEMBER count1 AS 'Count(Crossjoin([Measures].[Amount], [Date].[Calendar Year].[Calendar Year]))'
MEMBER count2 AS 'Count(DrilldownLevel([Department].[Departments]))'

SELECT  {count1, count2} ON 0 FROM [Adventure Works]
WHERE [Account].[Account Number].&[4]

有没有人知道为什么在WHERE子句中添加“[Account]。[Account Number]。& [1]”会导致Count()返回null值的单元格?

此外,如果我们将查询更改为以下内容,它似乎会给我们正确的结果。有谁知道使用Crossjoin是否是解决问题的正确方法?

WITH MEMBER count1 AS 'Count(Crossjoin(Crossjoin([Measures].[Amount], [Date].[Calendar Year].[Calendar Year]), [Account].[Account Number].&[1]))'
MEMBER count2 AS 'Count(Crossjoin(DrilldownLevel([Department].[Departments]), [Account].[Account Number].&[1]))'

SELECT {count1, count2} ON 0 FROM [Adventure Works]

谢谢,

费雯丽

1 个答案:

答案 0 :(得分:0)

尝试:

WITH
MEMBER [Measures].[count1] AS
    Count(NonEmpty([Date].[Calendar Year].[Calendar Year],[Measures].[Amount]))
MEMBER [Measures].[count2] AS
    Count(NonEmpty([Department].[Departments].[Departments].Members,[Measures].[Amount]))
SELECT
{
    [Measures].[count1],
    [Measures].[count2]
} ON 0
FROM [Adventure Works]
WHERE [Account].[Account Number].&[1]