【发布时间】:2013-08-11 04:03:20
【问题描述】:
我正在尝试创建一个 MDX 查询,以便稍后与 SSRS 一起使用。从有效的基本查询开始:
Select NON EMPTY {
[Measures].[Score %]
,[Measures].[Month Key]
} on Columns,
NON EMPTY {
([Date].[YMD].[Month Name].&[201301])
* FILTER([Customer].[Customer Full Name].[Customer Full Name].members,
([Measures].[Score %], [Date].[YMD].&[201301]) <> null
AND ([Measures].[Score %], [Date].[YMD].&[201301]) <> 0 )
} on Rows
from [Cube]
但这只是一个月。在 SSRS 中,我希望能够选择多个月份,因此我将查询更改为:
Select NON EMPTY {
[Measures].[Score %]
,[Measures].[Month Key]
} on Columns,
NON EMPTY {
([Date].[YMD].[Month Name].&[201301] : [Date].[YMD].[Month Name].&[201307])
* FILTER([Customer].[Customer Full Name].[Customer Full Name].members,
([Measures].[Score %], ([Date].[YMD].&[201301] : [Date].[YMD].&[201307]))<> null
AND ([Measures].[Score %], ([Date].[YMD].&[201301] : [Date].[YMD].&[201307])) <> 0 )
} on Rows
from [Cube]
但这里我得到一个错误: 函数需要一个字符串或数字表达式作为 1 参数。使用了元组集表达式。
据我了解,这是因为我要在我的系列中返回多个月,而它预计是一个月。所以我写下一个查询:
With
Set [QC relation]
as FILTER([Customer].[Customer Full Name].[Customer Full Name].members,
([Measures].[Score %], [Date].[YMD].currentmember) <> null
AND ([Measures].[Score %], [Date].[YMD].currentmember) <> 0 )
Select NON EMPTY {
[Measures].[Score %]
,[Measures].[Month Key]
} on Columns,
NON EMPTY {
([Date].[YMD].[Month Name].&[201301] : [Date].[YMD].[Month Name].&[201307])
* [QC relation]
} on Rows
from [Cube]
但这里似乎我的过滤器无法正常工作。它返回每个月数据中带有分数的所有行,所以我有很多空值。
如何在没有空值的情况下获得每个月的正确结果? 我在 SQLServer2008 上使用 SSMS/SSAS
谢谢
【问题讨论】: