Forum Discussion
Losing context transition by using filter
- 2 years ago
pankajk83
As I mentioned in my previous reply, there is absolutely no difference, in this case, between using FILTER - ALL or FILTER - VALUES. In fact VALUES, DISTINCT, ALLSECTED will all perform as ALL because the is no outer filter context.
What you are missing here is that the filter argument of CALCULATE replaces the filter context created by CALCULATE. When placed in a calculated column, CALCULATE converts all the columns of the current row of the table into a newly created filter context. When you use FILTER - Table you actually replace that filter context with a new one. Except this time the new filter context includes all the rows, not only the current row. That is the very same effect of FILTER - ALL ( Table ).
When you use FILTER - ALL ( Table[Column] ) you only replace that column in the filter context created by CALCULATE but the rest of that filter remains.
My recommendation, avoid using CALCULATE in creating calculated columns but rather try to rely on a NoCALCULATE approach.
correct me if I'm wrong but guessing:
Are you using CALCULATE() to make a calculated column? If that is the case that might be causing you trouble. Let me explain more about the logic:
single calculate makes the SUM() over the table, because there is no context transition at all. the measure would be working fine in a matrix if it's calculated in a measure, not in a column.
I don't know why the other two are working fine, but my theory is that ALL() is forcing to make the calculate in every different row.
It would be very useful to us you share the pbix file or your data to run some tests.
Hope been useful.
PD: sorry about my English still learning.