user716255
user716255

Reputation: 443

Power BI Visualization Month is not Sorting

The graphs represents Oct, Nov and Dec of 2020. And Jan 2021. How do I make Power BI sort by month and year? In the [Data] section, I told Power BI to sort by date, but the visualization is not updating. How do I fix this?

enter image description here

enter image description here

Upvotes: 0

Views: 6609

Answers (1)

teylyn
teylyn

Reputation: 35900

It looks like you have removed parts of the date hierarchy. That makes the axis a categorical axis instead of a timeline.

This results in the wrong sort order for the months. It is now sorting descending by month number, 12, 11, 10 and 1.

You may want to look into using a calendar table or adding a few sort helper columns to your source table.

The screenshot shows a similar scenario:

enter image description here

I add a sort column to the data source and use the Sort By command in the data model to sort the Month Name column by the Date column.

enter image description here

After that, the visual shows in the correct order.

enter image description here

Edit: Another approach can work if you only have one date for each month, so that will not work if you have many dates contributing to each of the monthly bars. My data only has one date per month and category, so I can just use the "Date" in the axis instead of the "Date Hierarchy". This retains the time axis properties and does not turn the axis into a categorical axis.

enter image description here

Upvotes: 2

Related Questions