Forum Discussion
Sort months previous year against current year
Hi. I am trying to create a bar chart dashboard, which would compare previous months year against the current one.
So I would like to see:
Jan2019 Jan2020 Feb2019 Feb2020 etc.
What is the easiest way to sort the bars in that order?
At the moment it sorts as Jan2019 Feb2019(...) Jan2020 Feb2020
hi munchkin666
For your case, you could use sort by column in power bi to get it.
https://radacad.com/sort-by-column-in-power-bi
Then just create a order column as this:
Order = MONTH([Date])*10000+YEAR([Date])Then selected YearMonth column, click ->sort by columns->Order
and here is sample pbix file, please try it.
Regards,
Lin
5 Replies
- parry2k
Super User
munchkin666 Change my blog post on date dimension which shows the sorting option for similar columns.
https://perytus.com/2020/05/22/create-a-basic-date-table-in-your-data-model-for-time-intelligence-calculations/I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.⚡
- amitchandak
Super User
Create a sort column like
Month Sort = format([Date],"MMYYYY")
And use that sort column for Month Year column you have as of now
https://docs.microsoft.com/en-us/power-bi/desktop-sort-by-column
- munchkin666
Helper II
Unfortunatley it didnt work. Do you have any other ideas? I would apprecaite any help. I only want to put the columns in a different order
Jan 2019 Jan2020 Feb2019 Feb2020 etc
- parry2k
Super User
munchkin666 did you looked at the post I mentioned before, there is sort by column.
What else did you try? Just saying "it didn't work" doesn't provide enough information about what you have tried and what is not working?
- v-lili6-msft
Community Support
hi munchkin666
For your case, you could use sort by column in power bi to get it.
https://radacad.com/sort-by-column-in-power-bi
Then just create a order column as this:
Order = MONTH([Date])*10000+YEAR([Date])Then selected YearMonth column, click ->sort by columns->Order
and here is sample pbix file, please try it.
Regards,
Lin