Forum Discussion

littlepatos2's avatar
littlepatos2
Regular Visitor
2 years ago
Solved

Sorting Years and Months in Line Chart

I have a dataset with 2 years of retail transactions and the data includes Month and Year columnhs.  I am trying to create a line chart to show decline in total cost over years and months but i can't get it to sort correctly.

Data 

 

  • littlepatos2 You will need a numeric Sort By column for your Month, something like MONTH('Table'[Date]) and then set that as your Sort By column for your alphanumeric month name column.

4 Replies

  • littlepatos2 ,
    Create a new month table with Months and Month Number. Sort Months by the Month number. Connect this table to original date table or whichever table you are pulling fields from on Month. Pull month from this new table into line chart. 

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    littlepatos2 You will need a numeric Sort By column for your Month, something like MONTH('Table'[Date]) and then set that as your Sort By column for your alphanumeric month name column.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi littlepatos2 ,

    First of all, many thanks to  for your very quick and effective replies.

    I can't open the link.

    Based on my testing, please try the following methods:

    1.Create the simple table.

    2.Select the Date column and choose the sort by values column.

    3.The result is shown below.

    Best Regards,

    Wisdom Wu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Anonymous's avatar
    Anonymous
    Not applicable

    In your semantic model, create a column that creates the correct sort order.  For example, 2401 for January 2024, 2402 for February 2024, etc....  Then use that field instead for your X axis.