使用GENERATE连接Rank和Member Name

时间:2014-05-29 10:36:47

标签: ssas mdx olap

以下内容来自MSDN:http://msdn.microsoft.com/en-us/library/ms144726.aspx

WITH 
SET OrderedCities AS Order
   ([Geography].[City].[City].members
   , [Measures].[Reseller Sales Amount], BDESC
   )
MEMBER [Measures].[City Rank] AS Rank
   ([Geography].[City].CurrentMember, OrderedCities)
SELECT {[Measures].[City Rank],[Measures].[Reseller Sales Amount]}  ON 0 
,Order
   ([Geography].[City].[City].MEMBERS
   ,[City Rank], ASC)
    ON 1
FROM [Adventure Works]

是否可以使用GENERATE函数将排名和城市连接成一列。结果如下所示:

enter image description here


修改

所以以下内容必须越来越近了:

WITH 
SET OrderedCities AS Order
   ([Geography].[City].[City].members
   , [Measures].[Reseller Sales Amount], BDESC
   )
MEMBER [Measures].[City Rank] AS Rank
   ([Geography].[City].CurrentMember, OrderedCities)

MEMBER [Measures].[memberName] AS
    '[Geography].[City].CurrentMember.name'
MEMBER [Measures].[memberValue] AS
    '[Measures].[City Rank].value'
MEMBER [Measures].[concat] AS  
//  [Measures].[memberName] + [Measures].[memberValue]//<<this errors
//  '[Measures].[memberName] & [Measures].[memberValue]'//<<this errors
    '[Measures].[memberName] + [Measures].[memberValue]'//<<this errors

SELECT 
    {[Measures].[City Rank],
    [Measures].[memberName],
    [Measures].[memberValue],
    [Measures].[concat],
    [Measures].[Reseller Sales Amount]}  ON 0 
,Order
   ([Geography].[City].[City].MEMBERS
   ,[City Rank], ASC)
    ON 1
FROM [Adventure Works]

1 个答案:

答案 0 :(得分:0)

以下内容应该有效:

  MEMBER [Measures].[concat] AS 
    cstr(RANK( [Geography].[City].currentmember, orderedcities)) +'.'+ 
    [Geography].[City].currentmember.name 

您仍然必须使用演示程序来摆脱第一个冗余列。

菲利普,