cancel
Showing results for 
Search instead for 
Did you mean: 
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
Microsoft
Microsoft


@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
Winner of T-Shirt Design

Power BI T-Shirt Design Challenge 2023

Find out who won the T-Shirt Design Challenge and the top 3 finalists.

March 2023 Update3

Power BI March 2023 Update

Find out more about the March 2023 update.