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
enswitzer
Helper III
Helper III

Sort Column Order

I have created a matrix visual that shows Target and Actual Dates. However, when I display these, it auto sorts them in alphabetical order such that the Actual date is on the right of the Target date. How can I show these in the reverse order (all the tutorials I have found have been for numbers rather than text)

 

enswitzer_0-1599162037190.png

 

Below are visualization set up and example of how my data is stored:

 

enswitzer_1-1599162100992.png

enswitzer_3-1599162158926.png

 

 

 

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @enswitzer 

 

= Table.AddColumn(#"Changed Type", "Sort", each if [#"Target & Actual"] = "Target" then 1 else 2)

 

Then Sort the Target & Actual column by this sort column.

Result is as below.

4.png

You can download the pbix file from this link: Sort Column Order

 

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

 

View solution in original post

4 REPLIES 4
v-rzhou-msft
Community Support
Community Support

Hi @enswitzer 

Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file from your Onedrive for Business.

 

Best Regards,

Rico Zhou

v-rzhou-msft
Community Support
Community Support

Hi @enswitzer 

 

= Table.AddColumn(#"Changed Type", "Sort", each if [#"Target & Actual"] = "Target" then 1 else 2)

 

Then Sort the Target & Actual column by this sort column.

Result is as below.

4.png

You can download the pbix file from this link: Sort Column Order

 

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

 

amitchandak
Super User
Super User

@enswitzer , in your table, create a new column

Target sort = if([Target & Actual] = "Target", 1, 2)

and mark this a sort column

https://docs.microsoft.com/en-us/power-bi/desktop-sort-by-column

dedelman_clng
Community Champion
Community Champion

Hi @enswitzer  - 

 

This is by no means an "elegant" solution, but it works.

 

Create a new "dimension" table that has two columns: "Target & Actual" and "SortOrder". Something like

 

Tar-Act = 
SUMMARIZE(Table, 
        Table[Target & Actual], 
        "SortOrder", IF([Target & Actual] = "Target", 1, 2)
)

 

Create a relationship between this new table and your fact table (1 to many), based on Target & Actual.

 

Finally, highlight "Target & Actual" in the new table, go to Column Tools, select "Sort By Column" and choose "SortOrder". Put "Target & Actual" from the dimension table into the matrix, and it should sort the way you'd like.

 

Hope this helps

David

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.