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 SLICER USING DAX

Hello,

 

I have a problem that is 50% solved. I need to sort a column in numerical order but it is sorting as text. Also the column is dynamically filtered by a slicer that contains a percent datatype AND currency datatype. I was able to figure out how to sort the column when the perentage slicer was selected. The DAX was:

Sales$ := IF(ISCROSSFILTERED('Parameter'[calculations]),
SWITCH( TRUE(),
    VALUES('Parameter'[calculations]) = "YoY%",
SWITCH( TRUE(),
ABS([Sales$ YoY%]) < 0.1, FORMAT([Sales$ YoY%],"  0.0%"),
ABS([Sales$ YoY%]) < 1, FORMAT([Sales$ YoY%]," 0.0%"),
FORMAT([Sales$ YoY%],"0%")
),
    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 ())

Now, when I slice using the currency type, it sorts out of order like the numbers are text. See below. Can we come up with a modification to the DAX above to sort the currency as well? 

Screenshot (9)_LI.jpg

5 REPLIES 5
Anonymous
Not applicable

Did I not give you a solution to this problem in your previous post about it? You chose to ignore it, right? I'll repeat myself quickly here. Use buttons, bookmarks and simple measures for this. Don't try to squeeze a square peg into around hole... like some on this forum instruct you to do.

Hi! I ended up doing a bookmark as you suggested actually, but I knew that there was an easy fix to the DAX which was solved as well! I enjoy finding multiple solutions to the same problem just in case soemone else might run into the same issue. I appreciate your advice greatly. Thanks again

Anonymous
Not applicable

The issue with the solution you're trying to get is simple. If you format your number as $222.22, then... you'll have the following problems: 1) what about numbers that are greater by orders of magnitude, e.g., $222,222.22? Do you want to show numbers like '$[space space space space...]22.22' and '$222,222.22'? Because they have to be formatted like this to sort correctly. This is not only ugly, it's awfully brittle. What if your numbers, for some reason in the future, will have to be displayed in a different currency? Or, you'll change the granularity of the money unit? Your measure will immediately fall apart... A real solution to a problem is robust and easy to understand and implement. When you create it, you should also think about the future as requirements can change. But do as you wish, of course 🙂I showed you the right way.

I seeeeee! Great point! Yeah definitely sounds like it would be an issue if things have to change. Will use your methodology moving forward. It was pretty fast and easy to get done too 🙂 

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.

Top Solution Authors