MDX query Count() return null when we put [Account].[Account Number].&[1] in WHERE clause
In our Adventure Works cube, if we run the following query, we will get two null cells back, and it will only happen for some members in Account Number. Does anyone know why?
Query that will return two cells with null value:
WITH MEMBER count1 AS 'Count(Crossjoin([Measures].[Amount], [Date].[Calendar Year].[Calendar Year]))'
MEMBER count2 AS 'Count(DrilldownLevel([Department].[Departments]))'
SE开发者_如何学PythonLECT {count1, count2} ON 0 FROM [Adventure Works]
WHERE [Account].[Account Number].&[1]
Query that will return two cells with correct number:
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]
Does anyone know why adding "[Account].[Account Number].&[1]" in the WHERE clause will cause the Count() to return cell with null value?
Also, if we change the query to the following, it seems to give us the correct result. Does anyone know whether using Crossjoin is a right way to fix the problem?
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]
Thanks,
Vivien
Try:
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]
精彩评论