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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
jkneazle
Frequent Visitor

Sort by Parameter Measure (custom sorting)

I've been trying to custom sort the parameter I created for the dashboard but could not find a way to do so. Basically I need the viz to sort by:

  • If "Age Group" is selected, custom sort it to show "Under 25" on the top, followed by "25 to 29", and then "30 to 34", etc., with "60+" being the last.
  • If "Gender" is selected, custom sort it to show "Female" at the top and then "Male".
  • If "Country" is selected, custom sort it to show USA first, then Canada, then Mexico, etc. 

I saw some posts with similar requirements but none of them would work in my scenario. Any help is greatly appreciated. 

 

Below is the sample data file:

Employee NameHire DateGenderAgeCountry
John Smith3/15/2021Male28USA
Emily Johnson5/20/2021Female35Canada
David Lee1/10/2022Male32UK
Maria Garcia4/5/2022Female29Spain
Michael Wang2/18/2023Male26Australia
Sarah Brown7/12/2023Female31Germany
Ahmed Khan3/8/2024Male46UAE
Fatima Ali5/19/2024Female24Pakistan
James Johnson8/10/2021Male34United States
Emma Wilson10/5/2021Female31United Kingdom
Carlos Sanchez3/22/2022Male29Spain
Olivia Li6/15/2022Female26China
Daniel Nguyen2/18/2023Male37Canada
Sofia Rossi5/20/2023Female33Italy
Mohamed Ali1/7/2024Male61Egypt
Mia Kim4/2/2024Female29South Korea
Lucas Silva7/12/2024Male58Brazil
Isabella Müller10/30/2024Female43Germany
Christopher Smith2/28/2021Male36Australia
Isabelle Tremblay6/10/2021Female30Canada
Juan Martinez4/15/2022Male33Mexico
Sophie Dupont8/22/2022Female29France
Alex Kim3/5/2023Male53South Korea
Elena Petrova6/18/2023Female27Russia
Ahmed El-Sayed2/12/2024Male31Egypt
Olivia Chan5/30/2024Female26Singapore
Matteo Bianchi8/9/2024Male34Italy
Emilia Schmidt11/27/2024Female32Germany

 

Below is a screenshot of the visual and the slicer parameter: currently it's automatically sorted to show headcount count descending. I would like for it to show a custom sort instead. 

parameter sort snapshot agegroup.png

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@jkneazle , Make sure for all those columns, you create a sort column and mark that as a sort column. You can create sort column using the same column in power query and then mark it sort column in data view.

 

If you create a sort column, to avoid circular dependency  you need do like

Gender 1 = [Gender]

 

Gender Sort   = if([Gender] = "Female",1, 2)

 

Then Mark Gender Sort as a sort column for Gender 1. and use Gender 1 in Visual

 

How to Create Sort Columns and Solve Related Errors:
https://www.youtube.com/watch?v=KK1zu4MBb-c

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Share the download link of the PBI file with the Age Group column and visuals already created.


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

@jkneazle , Make sure for all those columns, you create a sort column and mark that as a sort column. You can create sort column using the same column in power query and then mark it sort column in data view.

 

If you create a sort column, to avoid circular dependency  you need do like

Gender 1 = [Gender]

 

Gender Sort   = if([Gender] = "Female",1, 2)

 

Then Mark Gender Sort as a sort column for Gender 1. and use Gender 1 in Visual

 

How to Create Sort Columns and Solve Related Errors:
https://www.youtube.com/watch?v=KK1zu4MBb-c

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

This worked for me. Thank you!! 

Helpful resources

Announcements
Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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

Top Solution Authors