Forum Discussion

tbennett93's avatar
tbennett93
Frequent Visitor
4 years ago
Solved

How does CALCULATE know which rows to aggregate based on the table returned by the FILTER function?

My question is regarding how the CALCULATE function is able to 'know' which results to aggregate over based on the table that is returned by the FILTER function.    -CALCULATE takes a filter argume...
  • johnt75's avatar
    4 years ago

    Its all to do with data lineage. When passing a table to CALCULATE, whether it be multiple columns or a single column, CALCULATE knows which columns in the model that refers to, either because it is directly from those columns or you have used TREATAS to explicitly tell it.

    Because it knows which columns they are, the filter is applied to those columns and will then trickle around the model according to the relationships which have been set up.

    In the PREVIOUSDAY example, the column of dates which is passed in to the function is typically from the date table, and that is often set up to filter the fact tables, so that any filters applied to the date table will automatically pass down to the fact tables.