MDX Get MAX MEMBER_KEY from Dimension

放肆的年华 提交于 2019-12-10 18:49:23

问题


I have a very simple SSAS dimension which looks like this:

Dimension Name: DimKeyword

1 Attribute: Keyword with KeywordID as the KeyColumn and Keyword (name) as the NameColumn

Using MDX, I want to get one row with the Max MEMBER_KEY for the DimKeyword dimension (without listing all the Keywords), so far I have:

WITH MEMBER KeywordID as
[Dim Keyword].[Keyword].currentmember.MEMBER_KEY
SELECT {KeywordID} on COLUMNS
FROM [Some Cube]

Although this seems to only return 0 (which I assume is for the member ). Can anyone help?

Thanks!


回答1:


You can use the max function:

WITH MEMBER [Measures].[Max key] AS
    Max([Dim Keyword].[Keyword].Members, [Dim Keyword].[Keyword].currentmember.MEMBER_KEY)
SELECT {[Measures].[Max key]} on COLUMNS
FROM [Some Cube]

And if you want to have the Keyword member that has the highest MEMBER_KEY, you can use:

TopCount([Dim Keyword].[Keyword].Members, 1, [Dim Keyword].[Keyword].currentmember.MEMBER_KEY).Item(0).Item(0)


来源:https://stackoverflow.com/questions/12532704/mdx-get-max-member-key-from-dimension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!