Hello @Nurry90,
As suggested earlier, when a “FORMAT()” function is used it converts the numericals into the text format and that’s what it’s actually happening here in this case as well.
And therefore, we’ll have to rely on an alternative approach or a trick. So the trick here is, to create another measure just for sorting purposes. Below is the measure provided for the reference purposes -
Sorting Measure =
VAR _Total_Sales_Sort =
IF( ISBLANK( [Total Sales 1] ) ,
BLANK() ,
RANKX( ALL( Products ) , [Total Sales 1] , , DESC ) )
VAR _Total_Costs_Sort =
IF( ISBLANK( [Total Sales 1] ) ,
BLANK() ,
RANKX( ALL( Products ) , [Total Costs] , , DESC ) )
VAR _Total_Profits_Sort =
IF( ISBLANK( [Total Sales 1] ) ,
BLANK() ,
RANKX( ALL( Products ) , [Total Profits 1] , , DESC ) )
VAR _Percentage_Profit_Margin_Sort =
IF( ISBLANK( [Total Sales 1] ) ,
BLANK() ,
RANKX( ALL( Products ) , [% Profit Margin 1] , , DESC ) )
RETURN
SWITCH( TRUE() ,
SELECTEDVALUE( 'Metric Selection'[Metric] ) = "Total Sales" , _Total_Sales_Sort ,
SELECTEDVALUE( 'Metric Selection'[Metric] ) = "Total Costs" , _Total_Costs_Sort ,
SELECTEDVALUE( 'Metric Selection'[Metric] ) = "Total Profits" , _Total_Profits_Sort ,
SELECTEDVALUE( 'Metric Selection'[Metric] ) = "% Profit Margin" , _Percentage_Profit_Margin_Sort ,
_Total_Sales_Sort )
Once this measure is created, put it in a table visual and sort it from highest to lowest order i.e., Rank 1 will be considered as highest and last rank will be considered as lowest. Below is the screenshot provided for the reference -
As you can see in the above screenshot, highest sales is ranked 1 and so on and so forth.
But as soon as you select, “% Profit Margin” metric, see what happens -
So now, as you can see, it’s sorting the “% Profit Margin” results from highest order to the lowest ones.
And finally, since this measure is just created for sorting purposes. Simply hide this column by dragging the header from right-to-left. Below is the screenshot of the final results provided for the reference -
I’m also attaching the working of the PBIX file for the reference purposes.
Hoping you find this useful and meets your requirements that you’ve been looking for.
Note: Since you haven’t posted the working or your demo PBIX file, please make the changes accordingly as per your scenario requirements.
Thanks and Warm Regards,
Harsh
FORMAT example - Harsh.pbix (660.3 KB)