Forum Discussion

sash's avatar
sash
Frequent Visitor
9 years ago
Solved

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 explai...
  • mattbrice's avatar
    9 years ago

    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...