Forum Discussion

MCacc's avatar
MCacc
Icon for Helper IV rankHelper IV
2 years ago
Solved

Dax to order column based on another column

Is it possible to explicitly create a calculated column using a dax expression to order a column based on values of another column? 

 

I have a a slicer wich has to follow the sorting I have set in PowerQuery but somehow it doesn't work in my front end since it shows the values in the filter ordered alphabetically:

 

I'd like the slicer to follow this order:

IndexField
1Germany
2Austria
3Italy
4New Zeland
5France

I also cannot use Sort Column in the data field because it returns an error of too many values for that specific row. 

 

I tried many times to clear the chace, remove the enable load of the table, and so on.. But the front end refues to reflect what is shown in my PowerQuery

 

So I'm looking for some sort of ORDER BY but that can be used in a calculated column.

 

Any ideas? thank you for your help

3 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    MCacc You should be able to create a sort by column in Power Query and use that as your Sort By column, something like:

    if [Country] = "Germany" then 1 else if [Country] = "Austria" then 2 else if [Country] = "Italy" then 3 else if [Country] = "New Zealand" then 4 else 5

    Not sure why you are having issues with your current Sort By unless you have multiple different countries that match the same sort by value.