开发者

Second MAX through MDX

开发者 https://www.devze.com 2022-12-31 00:01 出处:网络
I can get the MAX() of some Measure based on Dimensions specified. I have no issues with that. What I am looking for is Second MAX(). Means if I sort th开发者_运维知识库e some Measures in DESC order i

I can get the MAX() of some Measure based on Dimensions specified. I have no issues with that. What I am looking for is Second MAX(). Means if I sort th开发者_运维知识库e some Measures in DESC order it is 5,4,3,2,1

With MAX() I can get 5 but I want 4. How do I compute that?


Use the EXCEPT keyword to knock out the top one from the top two set:

SELECT
    [Measures].[YourMeasure]
ON 0,
NON EMPTY
{
    EXCEPT
    (
        TOPCOUNT( [Date].[Date].[Date], 2, [Measures].[YourMeasure] ),
        TOPCOUNT( [Date].[Date].[Date], 1, [Measures].[YourMeasure] )
    )
}
ON 1
FROM [YourCube]
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号