Forum Discussion
Sort months in chronological order
- 10 years ago
Hi ArtFi. Can you combine your desired month number with a year prefix to give it a list of one-to-one values? For example, if you want 2015 to be ordered Jan then Feb etc., they would be numbered 201501, 201502. If you wanted 2016 to be ordered Mar, Jan, Feb, then March would still get 201601, then 201602 for Jan and 201603 for Feb. You'd just need to find some way to define the custom sort order in your column, either through a conditional column or maybe hard-coding the values in an Excel table.
If it's just that a year doesn't start with January because there is no January for that year (e.g., no sales for that month), you could still use the YYYYMM format to sort your months, and if the year starts with March, it won't hurt your chronological sort order anyway.
Hi Anandav,
Thanks for your response.
Unfortunately, I am using direct query so those formula's aren't supported. Instead I used sql to generate the month text and month ranking in my data set.
It's sorting in the splicer, but not filtering in the visual. Which is mind-boggling as it's the same data!
Hi FrugalEconomist,
I tried doing the same but using Excel. I have a date field, I added columns yyyymmdd and month name.
In Power BI Data view, I selected MonthName column and clicked on 'SortByColumn' option and selected DateIndex. The month was sorted correctly.
I have a before screenshot for comparison.
I think this is similar to having the DateIndex column in SQL.
If you could post your date, dateindex and month name fields may be that could shed some light.