Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

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

 

  • Anonymous's avatar
    Anonymous
    4 years ago

    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:

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

    Fact:

    Mode:

    3.Then add a line chart

     

    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.

8 Replies

  • lukiz84's avatar
    lukiz84
    Icon for Memorable Member rankMemorable 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's avatar
      Anonymous
      Not applicable

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

       

  • Anonymous's avatar
    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:

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

    Fact:

    Mode:

    3.Then add a line chart

     

    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's avatar
    lukiz84
    Icon for Memorable Member rankMemorable Member

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

    • Anonymous's avatar
      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. 

       

       

       

      • lukiz84's avatar
        lukiz84
        Icon for Memorable Member rankMemorable Member

        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