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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
v-binbinyu-msft
Community Support
Community Support

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
v-binbinyu-msft
Community Support
Community Support

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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