MDX中的案例陈述

时间:2013-12-26 19:05:43

标签: sql ssas mdx

我正在努力拉出前十名员工的名字

[Measures]. [count] is > 3 for priority 1, 
[Measures]. [count] is > 4 for priority 2 and
[Measures]. [count] is > 5 for priority 3. 

我只能写上面的任何一个。你能帮我写一下案例陈述吗?

目前代码为。

WITH MEMBER [Measures].[MCount] AS IIF([Measures].[Count]>3,[Measures].[Count],"")

SELECT 
NON EMPTY
{
[Measures].[MCount]
}
ON COLUMNS
,
{
NONEMPTY
(
TOPCOUNT(
[Item].[Names].CHILDREN,
10, 
[Measures].[Count] 
),
 [Measures].[Count]
)
}

ON ROWS FROM [item]
WHERE [Item].[Priority].&[1];

谢谢!

1 个答案:

答案 0 :(得分:0)

您可以使用以下生成和现有功能获得结果 -

WITH MEMBER [Measures].[MCount] AS 

CASE WHEN [Item].[Priority].CURRENTMEMBER IS [Item].[Priority].&[1] AND     Aggregate([Item].   [Priority].CURRENTMEMBER,[Measures].[Count]) > 3 THEN ""
 WHEN [Item].[Priority].CURRENTMEMBER IS [Item].[Priority].&[2] AND Aggregate([Item].                    [Priority].CURRENTMEMBER,[Measures].[Count]) > 4 THEN ""
 WHEN [Item].[Priority].CURRENTMEMBER IS [Item].[Priority].&[3] AND Aggregate([Item].            [Priority].CURRENTMEMBER,[Measures].[Count]) > 5 THEN ""
 END

SELECT 
NON EMPTY
{
[Measures].[MCount]
}
ON COLUMNS,
{
NONEMPTY
      (
        GENERATE({[Item].[Priority].&[1],[Item].[Priority].&[2],[Item].[Priority].&[3]}
        ,TOPCOUNT(EXISTING [Item].[Names].CHILDREN,10, [Measures].[Count] ),
        [Measures].[Count]
      )
}

ON ROWS FROM [item]