Forum Discussion

MKPBI_2805's avatar
MKPBI_2805
Frequent Visitor
6 years ago
Solved

Sorting based on a slicer values selection

Any help for Sorting based on a Slicer Value Section. Slicer will have the Column Names as List of Values used in a Table.

  • Hi,

     

    Here is my test sample:

    Please take following steps:

    1)Create a slicer table by Enter Data:

    2)Try this measure:

    Measure = 
    SWITCH (
        SELECTEDVALUE ( SlicerTable[Slicer] ),
        "Sort by Date", RANKX (
            ALLSELECTED ( 'Table' ),
            CALCULATE ( MAX ( 'Table'[Date] ) ),
            ,
            ASC,
            DENSE
        ),
        "Sort by Target_Sales", RANKX (
            ALLSELECTED ( 'Table' ),
            CALCULATE ( SUM ( 'Table'[Target_Sales] ) ),
            ,
            ASC,
            DENSE
        ),
        RANKX (
            ALLSELECTED ( 'Table' ),
            CALCULATE ( SUM ( 'Table'[Actual-Sales] ) ),
            ,
            ASC,
            DENSE
        )
    )

    3)Add this measure to the table visual, and set this visual sort by above measure:

    4)When selecting one value in slicer, the result shows:

    See my attached pbix file.

     

    Best Regards,

    Giotto

3 Replies

  • v-gizhi-msft's avatar
    v-gizhi-msft
    Community Support

    Hi,

     

    Here is my test sample:

    Please take following steps:

    1)Create a slicer table by Enter Data:

    2)Try this measure:

    Measure = 
    SWITCH (
        SELECTEDVALUE ( SlicerTable[Slicer] ),
        "Sort by Date", RANKX (
            ALLSELECTED ( 'Table' ),
            CALCULATE ( MAX ( 'Table'[Date] ) ),
            ,
            ASC,
            DENSE
        ),
        "Sort by Target_Sales", RANKX (
            ALLSELECTED ( 'Table' ),
            CALCULATE ( SUM ( 'Table'[Target_Sales] ) ),
            ,
            ASC,
            DENSE
        ),
        RANKX (
            ALLSELECTED ( 'Table' ),
            CALCULATE ( SUM ( 'Table'[Actual-Sales] ) ),
            ,
            ASC,
            DENSE
        )
    )

    3)Add this measure to the table visual, and set this visual sort by above measure:

    4)When selecting one value in slicer, the result shows:

    See my attached pbix file.

     

    Best Regards,

    Giotto

  • PattemManohar's avatar
    PattemManohar
    Community Champion

    MKPBI_2805  Don't think it is possible (As of today), to make sorting order by expression based (or selection based).

    But will be interested in other community members thougts as well on this.