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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Custom SORT

Hello,

 

I have created a Rank based on geography. But my geography sequence order is distorted.

 

I have created a Sort Order Table and assigned a sequence number. But when I use sort order geography than I am unable to populate Rank.

 

I am attaching my dashboard for reference.

 

Can anyone support me in creating CUSTOM SORT with Rank.

 

DAX Code:

 

Rank2 =
VAR __REGIONS = { "East Region", "West Region", "North Region", "Central Region" }
RETURN
    IF (
        SELECTEDVALUE ( DataTbl[Geography] )
            IN __REGIONS --rank will still show for US so a conditional statement needs to handle this.
                && ISINSCOPE ( DataTbl[Geography] ),
        --to remove rank from the total
        RANKX (
            FILTER ( ALL ( DataTbl[Geography] ), DataTbl[Geography] IN __REGIONS ),
            CALCULATE ( [ShrChgProA], KEEPFILTERS ( DataTbl[Product] = "Prod A" ) )
        )
    )

Rank Table without sortRank Table without sortSort SequenceSort Sequence

https://spaces.hightail.com/receive/BzqyRCwQmP 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@danextian Can you take a look on Custom Sort with respect to Rank.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

 

1. You can click the three dots in the upper-right corner of the visual object to choose which field to sort according to, and you can also choose ascending or descending order.

vkaiyuemsft_0-1716446924271.png

 

2. You can also directly click on the column name, after which the table visual object will sort according to the selected column.

vkaiyuemsft_1-1716446932423.png

 


3. In addition, I made some modifications to the measure to make sure the sorting is correct.

Rank2 = 
VAR __REGIONS = { "East Region", "West Region", "North Region", "Central Region" }
VAR _result = IF (
        SELECTEDVALUE ( DataTbl[Geography] )
            IN __REGIONS --rank will still show for US so a conditional statement needs to handle this. 
                && ISINSCOPE ( DataTbl[Geography] ),
        --to remove rank from the total
        RANKX (
            FILTER ( ALL ( DataTbl[Geography] ), DataTbl[Geography] IN __REGIONS ),
            CALCULATE ( [ShrChgProA], KEEPFILTERS ( DataTbl[Product] = "Prod A" ) )
        )
    )
RETURN
    IF(ISINSCOPE(DataTbl[Geography]) && _result = BLANK(),5,_result)

 

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

@danextian Can you take a look on Custom Sort with respect to Rank.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.