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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
AartiD
Helper I
Helper I

Custom sorting of values

I want to sort Difference amount column in below table from highest to lowest and from lowest to highest. The "Difference" column is a measure , I tried to create column of "Difference" to do custom sorting but getting error "Circular Dependency". Is there any other measure to sort difference amount?

 

 

AartiD_0-1753852352763.png

 

1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @AartiD 

It looks like you're using a matrix visual, which handles sorting a bit differently. In a matrix, sorting is applied within the context of each level of the hierarchy and not across the entire visual. So if you're trying to sort values across all rows regardless of the row grouping or hierarchy level, the matrix won't give you the behavior you expect. If you still want a similar effect, try moving the column in the lowest level of the hierarchy to the top.

 

Otherwise, If you want sorting to apply to all rows but without a hierarhcy, switch to a table visual instead. Unlike the matrix, the table doesn’t segment data by hierarchy, so sorting is straightforward and consistent across the entire result set.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

5 REPLIES 5
danextian
Super User
Super User

Hi @AartiD 

It looks like you're using a matrix visual, which handles sorting a bit differently. In a matrix, sorting is applied within the context of each level of the hierarchy and not across the entire visual. So if you're trying to sort values across all rows regardless of the row grouping or hierarchy level, the matrix won't give you the behavior you expect. If you still want a similar effect, try moving the column in the lowest level of the hierarchy to the top.

 

Otherwise, If you want sorting to apply to all rows but without a hierarhcy, switch to a table visual instead. Unlike the matrix, the table doesn’t segment data by hierarchy, so sorting is straightforward and consistent across the entire result set.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Superb, thank you so much.

AartiD
Helper I
Helper I

Sort by column is not working.

Hi @AartiD ,

Here’s the most reliable workaround for sorting a Power BI table by a measure when direct clicking doesn't work and calculated columns cause errors:

  • Create a Sorting "Helper" Column:

    1. Go to your Data view in Power BI Desktop.

    2. Select the table containing [Avg Sales] and [Current Month Sales].

    3. Create a New Column (not measure).

    4. Define it like this:
      Difference_Sortable = [Avg Sales] - [Current Month Sales]

    5. Now, go to your Report view.
    6. Replace the Difference measure in your table visual with this new Difference_Sortable column.
    7. You should now be able to click on the Difference_Sortable column header to sort highest to lowest and vice versa.
  • Why this works: Measures are dynamic. Calculated columns are static. By putting the calculation into a column, you create a static value that Power BI can reliably sort. The "circular dependency" usually comes from the measure trying to refer to something that then depends on the measure itself.
jaineshp
Memorable Member
Memorable Member

Hi @AartiD ,

Sorting "Difference" Measure:

  • Simplest Way: Just click the "Difference" column header in your table visual directly.

    • First click: Ascending (lowest to highest).

    • Second click: Descending (highest to lowest).

  • Why Calculated Column Fails: "Circular Dependency" means your measure relies on things that would then depend on the column, creating a loop. Measures dynamically calculate, columns are static.

  • No "Sort by Column" for Measures: You typically can't use "Sort by column" on a measure itself; it's for sorting one static column by another static column's values.

Just click the column header in the table visual – that's your quickest fix!

Hope this helps!

Best Regards,
Jainesh Poojara | Power BI Developer

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors