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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
sash
Frequent Visitor

DAX ALL vs. ALLEXCEPT

Hello,

 

I have a problem understanding the DAX filter functions. I want to do a GROUP BY SUM as a new column. I can get it to work using ALLEXCEPT, but not with the ALL function. Can anyone explain what I'm doing wrong?

 

This works as expected, returning total SUM of Value column of all the data: 

AllTable = CALCULATE(SUM(Sheet1[Value]); ALL(Sheet1)) 

 

This also works as expected, I get a SUM of grouped values by ColA and ColB:
ColumnAllExcept = CALCULATE(SUM(Sheet1[Value]); ALLEXCEPT(Sheet1; Sheet1[ColA]; Sheet1[ColB]))

 

I'm expecting that this returns the same as the previous formula (ColumnAllExcept), but it does not. It filters also on ColC, which it should not as it's explicitly defined that it should remove the filter from ColC:

ColumnAll = CALCULATE(SUM(Sheet1[Value]); ALL(Sheet1[ColC]))

 

The screenshot:

 

PowerBIForum_ALL_ALLEXCEPT.png

 

What am I doing wrong?

1 ACCEPTED SOLUTION
mattbrice
Solution Sage
Solution Sage

For a calculated column, when you use a CALCULATE every column in the table is transitioned from the row context to the filter context except when blocked by one of the 'ALL' functions like you used.  

 

In your last case you put :  ALL(Sheet1[ColC]), which if you look at row #1, while it does block the ColC value of 'Group XX' from transitioning to filter context, all the other columns still do. So it will sum up the 'Value' column for all the rows where 'ColA = Group 1'  and  'ColB = Group A' and 'Value = 1'.  It is this last filter why you are getting the results you are.  (And for completeness, it also filters the rows down to where 'AllTable = 136 and ColumnAllExcept = 10 )

 

So note when adding calculated columns is that unless explicity excluded, the filter context will also include other calculated columns.  So if you have two calculated columns that attempt to transition each other into the filter context, you end up with a circular dependency error which you may have seen.  Your use of 'ALL' and 'ALLEXCEPT' in the first two formulas avoids this as they block your newly created columns from being transitioned in. 

 

Hope this helps...

 

 

View solution in original post

2 REPLIES 2
mattbrice
Solution Sage
Solution Sage

For a calculated column, when you use a CALCULATE every column in the table is transitioned from the row context to the filter context except when blocked by one of the 'ALL' functions like you used.  

 

In your last case you put :  ALL(Sheet1[ColC]), which if you look at row #1, while it does block the ColC value of 'Group XX' from transitioning to filter context, all the other columns still do. So it will sum up the 'Value' column for all the rows where 'ColA = Group 1'  and  'ColB = Group A' and 'Value = 1'.  It is this last filter why you are getting the results you are.  (And for completeness, it also filters the rows down to where 'AllTable = 136 and ColumnAllExcept = 10 )

 

So note when adding calculated columns is that unless explicity excluded, the filter context will also include other calculated columns.  So if you have two calculated columns that attempt to transition each other into the filter context, you end up with a circular dependency error which you may have seen.  Your use of 'ALL' and 'ALLEXCEPT' in the first two formulas avoids this as they block your newly created columns from being transitioned in. 

 

Hope this helps...

 

 

Hi Matt,

 

Thank you very much for the explaination! I will look more into it, it seems that the DAX concepts are not as straightforward to understand as I thought. 🙂

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.