Mae*_*ude 4 ssas ssms mdx filter
我正在尝试制作一个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]
Run Code Online (Sandbox Code Playgroud)
但这只持续了一个月.在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]
Run Code Online (Sandbox Code Playgroud)
但是在这里我得到一个错误:<>函数需要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]
Run Code Online (Sandbox Code Playgroud)
但在这里似乎我的过滤器无法正常工作.它返回的所有行都在每个月的数据中得分,所以我有很多空值.
如何在没有空值的情况下获得每个月的正确结果?我在SQLServer2008上使用SSMS/SSAS
谢谢
重新处理您的查询我最终得到这个,让我知道它是怎么回事:
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,
SUM({[Date].[YMD].CURRENTMEMBER}, [Measures].[Score %])<> null
AND
SUM({[Date].[YMD].CURRENTMEMBER}, [Measures].[Score %])<> 0
)
} ON ROWS
FROM [Cube]
Run Code Online (Sandbox Code Playgroud)
或者更简单的版本可能会起作用:
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 %] <> null
AND
[Measures].[Score %] <> 0
)
} ON ROWS
FROM [Cube]
Run Code Online (Sandbox Code Playgroud)
编辑:第三次尝试,让我们看看这是否有效:
SELECT NON EMPTY
{
[Measures].[Score %]
,[Measures].[Month Key]
} ON COLUMNS,
NON EMPTY
{
([Date].[YMD].[Month Name].&[201301] : [Date].[YMD].[Month Name].&[201307])
*
[Customer].[Customer Full Name].[Customer Full Name].members
}
HAVING [Measures].[Score %] <> null
AND [Measures].[Score %] <> 0
ON ROWS
FROM [Cube]
Run Code Online (Sandbox Code Playgroud)