Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Pivot Top N into Columns

Hi All, I have a dataset with various fields that I want to pivot entirely. Please see the below example: I would like to pivot the table so that they are grouped by team and sorted by powe...
  • v-lid-msft's avatar
    6 years ago

    Hi Anonymous ,

     

    If you want to see the result in the table, We suggest matrix visual as a workaround.

     

    1. add a index column based on the order you describe

     

     

    Index =
    VAR t = [Team]
    VAR p = [Power Level]
    VAR n = [Name]
    VAR a = [Age]
    VAR t1 =
        FILTER ( ALL ( 'Table3' ), 'Table3'[Team] = t )
    VAR t2 =
        FILTER ( ALL ( 'Table3' ), 'Table3'[Team] = t && 'Table3'[Power Level] = p )
    VAR t3 =
        FILTER (
            ALL ( 'Table3' ),
            'Table3'[Team] = t
                && 'Table3'[Power Level] = p
                && 'Table3'[Age] = a
        )
    RETURN
        RANKX (
            t1,
            RANKX ( t1, [Power Level],, ASC, SKIP ) * 100
                + RANKX ( t2, [Age],, ASC, SKIP ) * 10
                + RANKX ( t3, [Name],, ASC, SKIP ),
            ,
            DESC,
            SKIP
        )

     

     

     

    Create a matrix, put the field in, and close the total.

     

     

    Then you can use the Index Slicer to control how many you want to show in matrix.

     

     

     

     

    BTW, pbix as attached.

     

    Best regards,

    Community Support Team _ Dong Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.