Forum Discussion

loomisfreeman19's avatar
loomisfreeman19
New Member
1 year ago
Solved

Column is not sorting by column

Hi, I have a column like this - "Quarter" and "QuarterSortValue"

 

QuarterQuarterSortValue
Q2/252025.2
Q1/252025.1
Q4/242024.4
Q3/242024.3
Q2/242024.2
Q1/242024.1
Q4/232023.4
Q3/232023.3
Q2/232023.2
2025 6 months 
2024 6 months 
2024 
2023 
Q2/252025.2
Q1/252025.1
Q4/242024.4
Q3/242024.3
Q2/242024.2
Q1/242024.1
Q4/232023.4
Q3/232023.3
Q2/232023.2
2025 6 months 
2024 6 months 
2024 
2023 

 

and a sort Quater by QuarterValueSort and still have this -

Should be like Q2/23 to Q2/25 in that order.

  • Hi loomisfreeman19 

    It looks like your QuarterSortValue column isn't defined correctly for sorting, as it contains blank values. A sort-by column must be one-to-one and complete – no duplicates or blanks – because the engine can't determine the correct order otherwise.

    If you're seeing this issue, it's also likely that the sort wasn't defined in Data View using the "Sort by Column" feature.

     

    To ensure proper sorting, make sure you:

    1. Ensure QuarterSortValue contains a unique and complete sort order (no blanks).

    *** Also, it's not recommended to mix different time hierarchies in the same column (e.g., quarters, half-years, years). For better model structure and clarity, you should have a proper Calendar table with separate columns for Year, Quarter, Half-Year, and so on – each with its own sorting logic.

    2. Once all these are set up correctly, your quarters should sort properly from Q2/23 to Q2/25.

    Go to Data View, select the Quarter column, and apply "Sort by Column: QuarterSortValue".

     

    3 Confirm that in your visual, the X-axis is using the Quarter column and that it's not auto-sorting by another field or being interpreted as text.

     

    Once all three are in place, your quarters should sort correctly from Q2/23 to Q2/25.

    The pbix with my example is attached ( it has a date table , you can use it for other files )

    More information about date tables here:
    https://radacad.com/all-in-one-script-to-create-date-dimension-in-power-bi-using-power-query/

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

5 Replies

  • Have you tried checking if the first column is already custom sorted by the second column from the column contextual tab?

  • Hi loomisfreeman19 

    It looks like your QuarterSortValue column isn't defined correctly for sorting, as it contains blank values. A sort-by column must be one-to-one and complete – no duplicates or blanks – because the engine can't determine the correct order otherwise.

    If you're seeing this issue, it's also likely that the sort wasn't defined in Data View using the "Sort by Column" feature.

     

    To ensure proper sorting, make sure you:

    1. Ensure QuarterSortValue contains a unique and complete sort order (no blanks).

    *** Also, it's not recommended to mix different time hierarchies in the same column (e.g., quarters, half-years, years). For better model structure and clarity, you should have a proper Calendar table with separate columns for Year, Quarter, Half-Year, and so on – each with its own sorting logic.

    2. Once all these are set up correctly, your quarters should sort properly from Q2/23 to Q2/25.

    Go to Data View, select the Quarter column, and apply "Sort by Column: QuarterSortValue".

     

    3 Confirm that in your visual, the X-axis is using the Quarter column and that it's not auto-sorting by another field or being interpreted as text.

     

    Once all three are in place, your quarters should sort correctly from Q2/23 to Q2/25.

    The pbix with my example is attached ( it has a date table , you can use it for other files )

    More information about date tables here:
    https://radacad.com/all-in-one-script-to-create-date-dimension-in-power-bi-using-power-query/

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

  • v-saisrao-msft's avatar
    v-saisrao-msft
    Community Support

    Hi loomisfreeman19,

    We haven’t heard back from you in a while regarding your issue. let us know if your issue has been resolved or if you still require support.

     

    Thank you.