Why isnt my dax custom sorting function working

Viewed 73

I am working on a Matrix visualization in Power BI. I would like to custom sort a field called [Risk]. There are three types of [risk]: low, moderate & high. I created a new column Sort Risk: Low = 1, moderate =2 and high =3 using dax. I told Power BI to sort by [Sort Risk].

Sort Risk = SWITCH([Risk], "low",1,"moderate",2,"high",3) 

enter image description here

Power BI is not doing it. What am I missing? enter image description here

1 Answers

I told Power BI to sort by [Sort Risk].

I don't think so. That should have failed because of a circular dependency. eg

enter image description here

Instead add [Sort Risk] in Power Query,

Table.AddColumn(#"NameOfPreviousStep", "Sort Risk", each if [Risk] = "Low" then 1 else if [Risk] = "Moderate" then 2 else if [Risk] = "High" then 3 else null, type number)
Related