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
vallemedef
Regular Visitor

ALL and custom sorting

Hi

 

I have custom sorting order and found out that ALL(main field) doesn't change context within calculation (returns 1 instead of 7), and I have to explicitly put in ALL(sorting field).

 

Have somebody met this behaviour previously? Is this correct behaviour or error?

 

From my perspective, [order field] presents in table implicitly, just for sorting, and creating measure I can't foresee that somewhen somebody applied custom sorting, the custom sorting field might be even not created yet.

vallemedef_0-1726568653421.png

p.s. just checked - ALLSELECTED works the same way

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

One of convenient ways to check which columns are involved in the filter context is to click "Run in DAX Query View" and check the query like below.

In this case, table visualization only contains month name column and sales column. However, query contains month number column as well because month name column is sorted by the month number column.

If month name column is not sorted by month number column, month number column will not be shown in the query.

 

Jihwan_Kim_0-1726591816489.png

 

Jihwan_Kim_1-1726591828313.png

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

One of convenient ways to check which columns are involved in the filter context is to click "Run in DAX Query View" and check the query like below.

In this case, table visualization only contains month name column and sales column. However, query contains month number column as well because month name column is sorted by the month number column.

If month name column is not sorted by month number column, month number column will not be shown in the query.

 

Jihwan_Kim_0-1726591816489.png

 

Jihwan_Kim_1-1726591828313.png

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
dharmendars007
Super User
Super User

Hello @vallemedef , 

 

This behavior is actually correct as per the DAX context rules in Power BI. When a custom sort field is applied, it becomes part of the filter context implicitly. To clear all context correctly, you must explicitly use ALL for both the main field and the sorting field.

 

Another example is when you use All function to remove context for months where if the months is sorted by month number than you should include both Month and month number in the All function

 

If you find this helpful , please mark it as solution and Your Kudos are much appreciated!

 

Thank You

Dharmendar S

LinkedIN 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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