Forum Discussion
CONVERT TEXT TO NUMBER
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:
oh, this is a DAX question.
Just change the data type of the measure to number:
- cuohanele6 years agoHelper I
That's the issue. It is greyed out. Used DAX ro crossfilter column to the slicers but the datatypes are different for all three dropdown options. One is percent and the others are currency. I can't switch them all to the same datatype
- artemus6 years agoMicrosoft Employee
You can add a new column (which doesn't depend on that one) which is numbers and can be set as the sort order for you main column
- v-juanli-msft6 years agoCommunity Support
Hi cuohanele
Create a dax column to convert text column to number:
text to number = CONVERT([text column],INTEGER)Then sort by this column to get proper order.
Or create another column besides your [Sales$] column,
then display [Sales$] column on your visual, but sort by the following column
Sales$ 2 = IF ( ISCROSSFILTERED ( 'Parameter'[calculations] ), SWITCH ( TRUE (), VALUES ( 'Parameter'[calculations] ) = "YoY%", SWITCH ( TRUE (), ABS ( [Sales$ YoY%] ) < 1, FORMAT ( [Sales$ YoY%], "Fixed" ), ABS ( [Sales$ YoY%] ) >= 1, FORMAT ( [Sales$ YoY%], "Fixed" ), BLANK () ), VALUES ( 'Parameter'[calculations] ) = "YoY Gap", CONCATENATE ( "$", FORMAT ( [Sales$ YoY Gap], "Fixed" ) ), VALUES ( 'Parameter'[calculations] ) = "Current Year Actuals", CONCATENATE ( "$", FORMAT ( [Sales$ CY], "Fixed" ) ), BLANK () ), BLANK () )Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.