Forum Discussion

SensingFailure's avatar
SensingFailure
Frequent Visitor
4 years ago
Solved

Dynamic Category Switching with Ranking Measures

I have a single table with user logon durations that looks as such: User Date Normal Hours Duration After Hours Duration Office 1 Office 2 Office 3 Keith 1/22/22 4.2 2.5 CT/TD CT/TD...
  • DataInsights's avatar
    4 years ago

    SensingFailure,

     

    Unfortunately, the RANKX function requires specifying the column to be ranked. However, you can use SWITCH in a measure to specify each column:

     

    Normal Use Rank = 
    SWITCH (
        TRUE,
        ISINSCOPE ( Citrix[Office 1] ), RANKX ( ALLSELECTED ( Citrix[Office 1] ), [Total Normal Use],, DESC ),
        ISINSCOPE ( Citrix[Office 2] ), RANKX ( ALLSELECTED ( Citrix[Office 2] ), [Total Normal Use],, DESC ),
        ISINSCOPE ( Citrix[Office 3] ), RANKX ( ALLSELECTED ( Citrix[Office 3] ), [Total Normal Use],, DESC )
    )

     

    Create a fields parameter using the three Office fields:

     

    Office Level = {
        ("Office 1", NAMEOF('Citrix'[Office 1]), 0),
        ("Office 2", NAMEOF('Citrix'[Office 2]), 1),
        ("Office 3", NAMEOF('Citrix'[Office 3]), 2)
    }

     

    Result:

     

    -----

     

    -----