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

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
ivan_xd
Frequent Visitor

Sorting characters after numbers

I have a measure that returns either a number or a "-" character. I have put this measure in a table visual and sorted it in descending order. It shows at the top the rows with measure="-" and then all the numbers in descending order. What can I do to have the "-" values at the bottom, and the numbers at the top in descending order?

7 REPLIES 7
v-gizhi-msft
Community Support
Community Support

Hi,

 

According to your description, i create a sample to test:

80.PNG

I create a measure first:

Measure = IF(MAX('Table'[Sales])<>BLANK(),SUM('Table'[Sales])*0.5,"-")

When i want to sort this measure in descending order, it shows the issue as you:

81.PNG

So for this issue, please try this rank measure:

rank = RANKX(ALLSELECTED('Table'),CALCULATE(SUM('Table'[Sales])),,DESC,Dense) 

It shows:

82.PNG

Then sort this rank measure in in descending order, the result shows:

83.PNG84.PNG

Here is my test pbix file:

pbix 

Hope this helps.

 

Best Regards,

Giotto Zhi

@v-gizhi-msft Thank you for your answer. Very clear. So, I asume there is no other solution? No hack to have Power Bi see a character as "lesser" than any numeric figure? I didn't want to have to tell the user: "Hey, you want to sort this one measure of your table? well too bad.... Wait! No, NO... don't click that, you're gonna see a bunch of dashes... you have to sort this other column right here if you want that other one sorted, because PBI does weird things sometimes. Oh, and for that other column... yeah, you see, each column has a special column if you want it sorted"

 

Oh, well...

Hi,

 

Please try to change the original measure to this:

 

Measure = SUM('Table'[Sales])*0.5+0

 

Then enter this to measure custom format in Model Pane:

 

#,#.00;#,#.00;"-"

 

15.PNG

Sort the table by this measure, it shows:

18.PNG

Tips: If you have more than one specifical character like '-', this workaround can not take effect.

        And i think there is no other easier solution to solve this issue.

Here is my changed pbix file:

pbix 

 

Best Regards,

Giotto Zhi

@v-gizhi-msft I'm not sure what you did. But, did you replace dashes with zeros and then format zero to be a dash? I don't think that will work when my measure takes negative values. I would love to have a table sorted natively like this: 

10
4
0
-12
-19435
-
-

 

I guess it is not possible to customize the default order.

Hi,

 

I think there is no other easier solution expect my first reply.

 

Best Regards,

Giotto Zhi

Greg_Deckler
Community Champion
Community Champion

Use a different character for "-" that comes after numerals, like "A" or ":" or "="



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...

Sadly that doesn't work. My measure does some calculation, if it fails it returns a character. No matter what character I use, it always is "greater" than any other number. 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

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.