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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
jcastr02
Post Prodigy
Post Prodigy

sorting rules

I'd like to be able to sort first by the number then by employee name.  Is there a way to do this like we do in excel - setting up rules of sorting?

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

On your Table.Matrix visual, click on the number column, press the Shift key and then click on the Employee name column. 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
v-luwang-msft
Community Support
Community Support

Hi @jcastr02 ,

Final value to be ranked =

Rank on Primary Measure (ascending)

+ Rank on Secondary Measure (ascending) / (Total Row Count + 1)

 

The first term is the Primary Measure rank, and the second term is the Secondary Measure rank scaled to be between 0 and 1 so that it can break ties in the Primary Measure rank.

 

In DAX, assuming you have two measures, [Primary Measure] and [Secondary Measure], to be ranked over all rows of Table:

Final Rank =
RANKX (
    ALL ( Table ),
    RANKX ( ALL ( Table ), [Primary Measure],, ASC )
        + DIVIDE (
            RANKX ( ALL ( Table ), [Secondary Measure],, ASC ),
            ( COUNTROWS ( ALL ( Table ) ) + 1 )
        )
)

Just replace with your table/measure names and it should work. 

 

And a similar case refer(sort by a measure ,if with the same value ,then sort by another value) :https://community.powerbi.com/t5/Desktop/RANKX-with-duplicate-values/m-p/2072218#M772408 

 

 

Best Regaards

Lucien

Ashish_Mathur
Super User
Super User

Hi,

On your Table.Matrix visual, click on the number column, press the Shift key and then click on the Employee name column. 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Greg_Deckler
Community Champion
Community Champion

@jcastr02 I don't believe that is a function quite yet of table and matrix visuals but you could create a composite key in Power Query to just concatenate the two columns and then use a Sort By column.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.