Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

PowerBI sort by Month Number

Hi,

 

I am trying to arrange my central date table by month number in order to have the line graph display January through December but I keep getting a cardinality error.

 

I have a central date table with more than one year, therefore I believe that might be the problem.


Could you please advice? 

 

Thanks

Aziza_0-1658832035951.pngAziza_1-1658832049968.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

Please try below steps:
1.Create a month table, and add a index column , then sort the month column by index

Month_sort:

vbinbinyumsft_0-1659088869983.png

2.Create a relationship between your month table and fact table

Fact:

vbinbinyumsft_1-1659088896253.png

Mode:

vbinbinyumsft_2-1659088914865.png

3.Then add a line chart

vbinbinyumsft_3-1659088942457.png

 

Best regards,
Community Support Team_ Binbin Yu
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

8 REPLIES 8
Anonymous
Not applicable

Hi @Anonymous ,

Please try below steps:
1.Create a month table, and add a index column , then sort the month column by index

Month_sort:

vbinbinyumsft_0-1659088869983.png

2.Create a relationship between your month table and fact table

Fact:

vbinbinyumsft_1-1659088896253.png

Mode:

vbinbinyumsft_2-1659088914865.png

3.Then add a line chart

vbinbinyumsft_3-1659088942457.png

 

Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lukiz84
Memorable Member
Memorable Member

Can you show me your date table after adding the DateSortColumn?

Anonymous
Not applicable

So I have tried your DAX two different ways as I couldn't close brackets. I get the same error for both. 

 

Aziza_1-1658917006653.png

 

Aziza_0-1658916984954.png

 

whats the second one? the first is correct and should work, i use the exact same setting in my date table... so it's weird

Anonymous
Not applicable

I tried the correct one and it is still giving the same error 😞

I have multiple years, could this be the issue? 

no, that's the default case ... can you send the pbx file?

lukiz84
Memorable Member
Memorable Member

Add a DateSortColumn to your Calendar table, like

 

DateSortColumn := 100 * YEAR(Calendar[Date]) + MONTH(Calendar[Date])

 

and apply this to your Month-Column as "Sort by".

Anonymous
Not applicable

Thanks for the reply. I am getting this error when I try to sort?

Aziza_0-1658913484808.png

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.