1

In CALCULATE we can use FILTER(tblname,..)

Or

FILTER(ALL(tblname),..)

I want to ask whether FILTER in CALCULATE adds or modifies (clears and adds new) the existing filter context?

variable
  • 8,262
  • 9
  • 95
  • 215

1 Answers1

1

The answer is yes. It adds a new filter when no filter exists on tblname or it replaces (removes the existing filter and adds the new filter) when a filter already exists on tablename or some of its expanded table columns when CALCULATE is called. Existing filters on non-related columns are unaffected.

apart from the first parameter in CALCULATE, that is the expression to be computed in the modified filter context, all the other parameters are called filter arguments, since their purpose is to change the filter context.

CALCULATE( expression, table[column] = value ) 

is internally translated by DAX to

CALCULATE( expression, FILTER( ALL( table[column] ), table[column] = value ) )
sergiom
  • 4,791
  • 3
  • 24
  • 32
  • 1
    So does it clear and add new context or modify the context – variable Jan 12 '21 at 08:58
  • yes, all the filter argument in CALCULATE can be seen as tables of one or more columns, and in that case they replace the existing filters on the same columns, or as filter modifiers like ALL or REMOVEFILTERS, that just remove the existing filter – sergiom Jan 12 '21 at 09:05
  • 1
    I improved the answer. I hope it's more clear now. – sergiom Jan 12 '21 at 09:50