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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Jn_01
Regular Visitor

Custom sort drop down for asc and desc options for my tabular visualization

sort1.png

 

Hello all,
I wanted to make custom sort dropdown for asc and desc options for my tabular visualization.

I am able to sort using Ascending/Descending when I am having unique values but my detailed report has same values repeated multiple time for different dates.

My meausre

rankmeasure =
IF(
SELECTEDVALUE(SortTable[SortOrder])="1"
,RANKX(ALLSELECTED('SortOrder'[api_for]),CALCULATE( MIN('SortOrder'[Order])),,ASC,Dense)
,RANKX(ALLSELECTED('SortOrder'[api_for]),CALCULATE( MIN('SortOrder'[Order])),,DESC,Dense)
)
is working fine for distinct values (Summary report)
But for detailed report with multiple values of api_for it is not working.

Thank you.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@lbendlin Thanks for your contribution on this thread.

Hi @Jn_01 ,

You can refer the following official documentation to sort the data of single or multiple fields in the visual directly just as @lbendlin referred:

Change how a chart is sorted in a report - Power BI | Microsoft Learn

vyiruanmsft_0-1718958518556.png

In addition, please update the formula of your measure as below and check if it can return the expected result...

rankmeasure =
VAR SummaryTable =
    SUMMARIZE(
        'SortOrder',
        'SortOrder'[api_for],
        "MinOrder", CALCULATE(MIN('SortOrder'[Order]))
    )
RETURN
IF(
    SELECTEDVALUE(SortTable[SortOrder]) = "1",
    RANKX(ALLSELECTED(SummaryTable), [MinOrder], , ASC, Dense),
    RANKX(ALLSELECTED(SummaryTable), [MinOrder], , DESC, Dense)
)

Best Regards

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

@lbendlin Thanks for your contribution on this thread.

Hi @Jn_01 ,

You can refer the following official documentation to sort the data of single or multiple fields in the visual directly just as @lbendlin referred:

Change how a chart is sorted in a report - Power BI | Microsoft Learn

vyiruanmsft_0-1718958518556.png

In addition, please update the formula of your measure as below and check if it can return the expected result...

rankmeasure =
VAR SummaryTable =
    SUMMARIZE(
        'SortOrder',
        'SortOrder'[api_for],
        "MinOrder", CALCULATE(MIN('SortOrder'[Order]))
    )
RETURN
IF(
    SELECTEDVALUE(SortTable[SortOrder]) = "1",
    RANKX(ALLSELECTED(SummaryTable), [MinOrder], , ASC, Dense),
    RANKX(ALLSELECTED(SummaryTable), [MinOrder], , DESC, Dense)
)

Best Regards

lbendlin
Super User
Super User

What prevents you from using the default sort options (clicking on the column headers) ?

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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