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
cuohanele
Helper I
Helper I

DYNAMIC SORTING

Hi everyone! In need of some assistance.

I created a dynamic format for a column in my table to be filtered by a specific slicer. Unfortunately, it is sorting the numbers like they are string. I used the code below:

Sales$ = IF(ISCROSSFILTERED('Parameter'[calculations]),
SWITCH( TRUE(),
    VALUES('Parameter'[calculations]) = "YoY%",
SWITCH( TRUE(),
ABS([Sales$ YoY%]) < 1, FORMAT([Sales$ YoY%],"0.0%"),
ABS([Sales$ YoY%]) >= 1, FORMAT([Sales$ YoY%],"0%"),
BLANK()
),
    VALUES('Parameter'[calculations]) = "YoY Gap", CONCATENATE("$", FORMAT([Sales$ YoY Gap],"0,0")),
    VALUES('Parameter'[calculations]) = "Current Year Actuals", CONCATENATE("$", FORMAT([Sales$ CY],"0,0")),
BLANK()), BLANK ())

When any of the options in the slicer is picked, it returns this column sorted out of order. See below for visual:

Screenshot (5)_LI.jpgScreenshot (6).png

So it is sorting something like this:
100
1
2
200
222
3
33

Thanks in advance!

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi @cuohanele

 

Using "format" function is to change the number into text format,so go to "column tools " in the menu bar to set the number into "percent" format.

Annotation 2020-08-07 151236.png

 

 
Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

 

 

View solution in original post

2 REPLIES 2
v-kelly-msft
Community Support
Community Support

Hi @cuohanele

 

Using "format" function is to change the number into text format,so go to "column tools " in the menu bar to set the number into "percent" format.

Annotation 2020-08-07 151236.png

 

 
Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

 

 

edhans
Super User
Super User

They are strings. The FORMAT() function  converts values to text. You'd need to have leading zeros to format correctly. I am not aware of a way to conditionally format numbers by number format (currency, percentage, etc.)



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

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.