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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

dynamic sort by measure filter

Hi All,

how can we achieve below requirement?

there is a metric slicer, if i choose 'AVERAGE' the it should sort Average measure by ASC order, elseif i choose 'DISMISSALS' then it should sort Dismissals measure by DESC order.

i am not able to achieve the sorting requirement

 

Data:

Batsman             Average Dismissals

Virat Kohli1005
Kedar Jadhav621
Rohit Sharma51.910
Shikhar Dhawan34.412
MS Dhoni24.779

 

Chart:

chart.PNGchart2.PNG

 

Thanks,

Raj

 

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

First create a slicer table as below:

Annotation 2020-09-07 140725.png

Then create 2 measures as below:

Measure = 
SWITCH(SELECTEDVALUE('Table (2)'[Slicer]),"Average",MAX('Table'[Average ]),"Dismissals",MAX('Table'[Dismissals]),BLANK())
Measure 2 = 
SWITCH(SELECTEDVALUE('Table (2)'[Slicer]),"Average" ,
RANKX(ALLSELECTED('Table'),'Table'[Measure],,ASC,Dense),
"Dismissals",
RANKX(ALLSELECTED('Table'),'Table'[Measure],,DESC,Dense))

And you will see:(make measure 2 as a tooltip field)

Annotation 2020-09-07 143702.png

 

Annotation 2020-09-07 140854.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

@Anonymous , Are able to sort on the measure(Using the three dots) on the visual. then it should sort or the whatever has been selected.

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
Anonymous
Not applicable

No Amit, using those 3 dots i cannot sort the way i need.

 if i choose 'AVERAGE' the it should sort common measure(Measure) by ASC order, elseif i choose 'DISMISSALS' then it should sort common measure(Measure) by DESC order

Hi @Anonymous ,

 

First create a slicer table as below:

Annotation 2020-09-07 140725.png

Then create 2 measures as below:

Measure = 
SWITCH(SELECTEDVALUE('Table (2)'[Slicer]),"Average",MAX('Table'[Average ]),"Dismissals",MAX('Table'[Dismissals]),BLANK())
Measure 2 = 
SWITCH(SELECTEDVALUE('Table (2)'[Slicer]),"Average" ,
RANKX(ALLSELECTED('Table'),'Table'[Measure],,ASC,Dense),
"Dismissals",
RANKX(ALLSELECTED('Table'),'Table'[Measure],,DESC,Dense))

And you will see:(make measure 2 as a tooltip field)

Annotation 2020-09-07 143702.png

 

Annotation 2020-09-07 140854.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
Greg_Deckler
Community Champion
Community Champion

@Anonymous - I believe that you would need a disconnected table and a single measure that switches between the average and dismissals based upon the slicer selection. In general, to use a measure in that way, you need to use the Disconnected Table Trick as this article demonstrates: https://community.powerbi.com/t5/Community-Blog/Solving-Attendance-with-the-Disconnected-Table-Trick/ba-p/279563



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...
Anonymous
Not applicable

Thanks Greg.

 

Infact i have created a disconnected table and a single measure that switches between the average and dismissals based upon the slicer selection. but i am stuck with the sorting - Average should sort by Asc and Dismissals should sort by Desc.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors