Forum Discussion

pankajk83's avatar
pankajk83
Regular Visitor
2 years ago
Solved

Losing context transition by using filter

Hi All,   Struggling to understand this behaviour of calculate. Newbie here. I have two tables. A sales table and a product table. I am creating a calculated column inside product table to to calcu...
  • tamerj1's avatar
    tamerj1
    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.