Forum Discussion
Month not getting sorted Correctly
- 9 years ago
Hi abhishek_300,
For Direct Query of tabular, It's so strange cause if you have Dates(Date column, Month no column, Month Name column,...) table and Fact table in your tabular with relationship of Date column, it will be sorted automatically when you use Month Name column in chart.
Could you please check your Tabular Model, properties of Month Name column, choose Sort By Column property and assign the Order Column for it?
https://msdn.microsoft.com/en-us/library/hh479566.aspx (Sort By Column)
Refer topic: https://www.simple-talk.com/sql/bi/creating-a-date-dimension-in-a-tabular-model/
hI,
Thanks for your reply.I am using direct query and I am creating dataset directly from the Power BI Pro. I am not using Power BI desktop.
So do I need to create an Order column on tabular model using below query
OrderColumn = Year*100+Month_Number.
So that will be 2017*100+1= 201701.
So does that mean I will have to show to the users 201701 and I cannot use the column with the value like January-2017 in the visual.
Hi abhishek_300,
You show January-2017 column but sort by order column, you need to do it in Power BI Desktop and publish pbix file.
- abhishek_3009 years agoFrequent Visitor
This filed is disabled has I have connected to the tabular model using direct query.
- tringuyenminh929 years agoMemorable Member
Hi abhishek_300,
For Direct Query of tabular, It's so strange cause if you have Dates(Date column, Month no column, Month Name column,...) table and Fact table in your tabular with relationship of Date column, it will be sorted automatically when you use Month Name column in chart.
Could you please check your Tabular Model, properties of Month Name column, choose Sort By Column property and assign the Order Column for it?
https://msdn.microsoft.com/en-us/library/hh479566.aspx (Sort By Column)
Refer topic: https://www.simple-talk.com/sql/bi/creating-a-date-dimension-in-a-tabular-model/
- abhishek_3009 years agoFrequent Visitor
Thanks tringuyenminh92,I change the sorting order in the properties of Tabular Model and now it is getting sorted correctly.
Thanks for your help
- anandav9 years agoSkilled Sharer
Hi tringuyenminh92,
I have created a calendar table in Power BI and I can sort by month. My data start from Jun 2016 to March 2017. The problem comes when the year increases – from 2016 to 2017. Then the date is displayed as 2017 months first and then 2016 months. i.e. Jan, Feb, Mar, Jun, Jul, Aug…….
I tried creating a column YYYYMM and tried to index the month name using that column in DAX. But I get an error “.. You cannot sort the Month Name column by YearMonthIndex. You cannot have more than one value in YearMonthIndex for the same value in Month Name.”
How can I sort the months so that the roll over of year will not cause a problem?
Thanks in advance.
- tringuyenminh929 years agoMemorable Member
Hi anandav,
Could i have your pbix file for observation? so I could quickly figure out solution for your sorting expectation.
- anandav9 years agoSkilled Sharer
Hi tringuyenminh92,
I solved the problkem using v-haibl-msft's suggestion here.
It's the same solution like you have suggested but it uses a column 'Month YYYY' column and sort that using the YearMonth column. That worked.
But I still couldn't figure out why I get the error when I try to sort the Month Name using the YearMonthIndex field,