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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
AmberJane
Helper II
Helper II

mins, hrs, days measure column not sorting correctly

This is a custom measure that is converting a whole number that represents minutes into mins, hrs and days but is not sorting how I would expect. Mins > Hrs > Days or vice versa. 

 

Any suggestios? 

AmberJane_0-1654800770161.png

 

1 ACCEPTED SOLUTION
Hariharan_R
Solution Sage
Solution Sage

Hi,

You can get the expected order using the reference table.

 

1. Create one table like below. You can use "Enter Data" option to create this static table.

Hariharan_R_0-1654839466720.png

2. Create one column in your main table in Power query layer. change it for your table column

 

= Table.AddColumn(#"Changed Type", "Type", each if Text.Contains([TTF], "mins") then "mins" else if Text.Contains([TTF], "days") then "days" else if Text.Contains([TTF], "hrs") then "hrs" else 0)

 

Hariharan_R_1-1654839535640.png

 

3. Connect table in step 1 and step 2 using the Type column

Hariharan_R_2-1654839620559.png

 

4. Create one calculated column in you main table using - 

Order = RELATED('Sort Table'[Order])

 

Hariharan_R_3-1654839707551.png

5. Select your main column and choose sort by column and select order.

Hariharan_R_4-1654839774388.png

 

Thanks

Hari

 

 

 

 

 

View solution in original post

1 REPLY 1
Hariharan_R
Solution Sage
Solution Sage

Hi,

You can get the expected order using the reference table.

 

1. Create one table like below. You can use "Enter Data" option to create this static table.

Hariharan_R_0-1654839466720.png

2. Create one column in your main table in Power query layer. change it for your table column

 

= Table.AddColumn(#"Changed Type", "Type", each if Text.Contains([TTF], "mins") then "mins" else if Text.Contains([TTF], "days") then "days" else if Text.Contains([TTF], "hrs") then "hrs" else 0)

 

Hariharan_R_1-1654839535640.png

 

3. Connect table in step 1 and step 2 using the Type column

Hariharan_R_2-1654839620559.png

 

4. Create one calculated column in you main table using - 

Order = RELATED('Sort Table'[Order])

 

Hariharan_R_3-1654839707551.png

5. Select your main column and choose sort by column and select order.

Hariharan_R_4-1654839774388.png

 

Thanks

Hari

 

 

 

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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