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
Erin001
Helper II
Helper II

Why "~" comes before "0" when sorting?

"~" and "0" ascii codes are 126 and 48, but "~" comes before "0" when sorting.

 

What I want to do is setting a dummy value at the very end of the list(e.g., after "z" if there's any item starts with "z").

 

Any ideas?

 

Thanks!

3 REPLIES 3
Eric_Zhang
Employee
Employee


@Erin001 wrote:

"~" and "0" ascii codes are 126 and 48, but "~" comes before "0" when sorting.

 

What I want to do is setting a dummy value at the very end of the list(e.g., after "z" if there's any item starts with "z").

 

Any ideas?

 

Thanks!


@Erin001

That alphabet order seems using a standard algorithm other than simply comparing the ascii codes. For example, capital D(asc 68) is less than c(97), however c is before D when sorting.

 

I'm not sure how you would like setting the dummy value, could you be more specific on your scenario? How would you like your data sorted?

 

Hi Eric,

 

Here's my case:

 

I have 2 slicers: 1. Project type(External/Internal), 2. Project Name (only list internal project names)

 

since I can't add filter to slicer 'Project Name' to display internal project names only, I have to put a dummy name for all external project there.

 

I would like to put the dummy value at the end of the list. I could use 'ZZZZZZZ', but I prefer chars like '_'/'~' etc.

 

 

 

Thanks!

GilbertQ
Super User
Super User

What I would suggest doing is then to create a new conditional column in the query editor.

When creating the conditional column you can then define and say if the value = "~" then 99999999 else make it the value from your column.

 

Then once that is loaded go back into the Data Model and under Modeling use the Sort by Column and use the conditional column you created above.

 

Decimal Places - Modeling.png





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

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.