Apply RANK function to a set according to alphabetical order

杀马特。学长 韩版系。学妹 提交于 2019-12-13 04:35:22

问题


Is it possible to create a measure that produces the rank of a set according to their alphabetical order i.e. Aleen should be 1 .... Zebedie should be ranked 101 (set has 101 items)

This does not work:

MEMBER [Measures].[Alphabetic_Rank] AS 
    RANK(
        [CustomerName].CurrentMember,
        ORDER(
            [CustomerName],
            [CustomerName],
            ASC
            )
        )

EDIT

A further example of trying to apply this is the following which also does not work:

WITH 
SET [orderedSet] AS
    ORDER(
    [Operator].members,
    [Operator].currentmember.name,
    BASC
    )
MEMBER [Measures].[newMeasure] AS
    RANK(
    [orderedSet].currentmember, 
    [orderedSet].members
    )
SELECT
   {} ON COLUMNS,
   [orderedSet] 
   * 
   [Measures].[newMeasure] ON ROWS
FROM [ourCube]

回答1:


How about using the NAME as order's numerical value :

MEMBER [Measures].[Alphabetic_Rank] AS 
    RANK(
        [CustomerName].CurrentMember,
        ORDER(
            [CustomerName].members,
            [CustomerName].currentMember.NAME,
            BASC
            )
        )

EDIT for the second part :

WITH 
SET [orderedSet] AS
    ORDER(
    [Operator].members,
    [Operator].currentmember.name,
    BASC
    )
MEMBER [Measures].[newMeasure] AS
    RANK(
    [Operator].currentmember, 
    [orderedSet]
    )
SELECT
   [Measures].[newMeasure] ON COLUMNS,
   [orderedSet] ON ROWS
FROM [ourCube]


来源:https://stackoverflow.com/questions/19930593/apply-rank-function-to-a-set-according-to-alphabetical-order

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