Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
MKPBI_2805
Frequent Visitor

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.

1 ACCEPTED SOLUTION
v-gizhi-msft
Community Support
Community Support

Hi,

 

Here is my test sample:

1.PNG

Please take following steps:

1)Create a slicer table by Enter Data:

2.PNG

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:

1.jpg

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

3.PNG5.PNG6.PNG

See my attached pbix file.

 

Best Regards,

Giotto

View solution in original post

3 REPLIES 3
v-gizhi-msft
Community Support
Community Support

Hi,

 

Here is my test sample:

1.PNG

Please take following steps:

1)Create a slicer table by Enter Data:

2.PNG

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:

1.jpg

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

3.PNG5.PNG6.PNG

See my attached pbix file.

 

Best Regards,

Giotto

amitchandak
Super User
Super User

@MKPBI_2805 , You have the option to choose a sort column, which means it is static. means no option to change.

https://docs.microsoft.com/en-us/power-bi/desktop-sort-by-column

 

What is that you want to achieve.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
PattemManohar
Community Champion
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. 





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.