Forum Discussion

tan_thiamhuat's avatar
tan_thiamhuat
Icon for Post Patron rankPost Patron
1 year ago
Solved

Power BI: Month - Sort By Month Number

I have this Month, which is Alphabetical, and sorted by the MonthNumber (1,2,3,...9,10,11,12) which is OK when we have whole set of data for the whole year starting in January. But if I have a set of...
  • Aala_Ali's avatar
    1 year ago

    Hi tan_thiamhuat 


    Create a Custom Sort Order Based on Your Dataset's Starting Month

    You need a custom sort column that aligns with your actual data range — in this case, starting from September.

    🔧Steps to Fix It:

    1. Create a calculated column (in your Date table or your Month table):

      DAX
       
      CustomMonthOrder =
      VAR StartMonth = 9 -- September (adjust as needed)
      RETURN
      MOD([MonthNumber] - StartMonth + 12, 12) + 1

      ✅This will create an order where:

      • September = 1

      • October = 2

      • ...

      • August = 12

    2. Sort your Month column by CustomMonthOrder:

      • Go to the Modeling tab

      • Select your Month column

      • Click "Sort by Column" → choose CustomMonthOrder

    3. Now, your visuals will show months in the correct order based on your dataset’s starting month, regardless of the calendar year.

      If my response resolved your query, kindly mark it as the Accepted Solution to assist others. Additionally, I would be grateful for a 'Kudos' if you found my response helpful 🙂