Forum Discussion
How does CALCULATE know which rows to aggregate based on the table returned by the FILTER function?
- 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.
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.
- tbennett934 years agoFrequent Visitor
Thanks for the response. Interesting that CALCULATE just knows which results have been filtered. I feel like this should be mentioned somewhere as I can imagine if I was trying to create DAX based purely on the documentation given the parameters/return types etc, this sort of thing would trip me up.
Is there anywhere I could learn more about this subject (data lineage etc)? It's not something I've ever come across.