Forum Discussion
CALCULATE With FILTER or Without Which is BETTER ?
These two formulas lead to the same results
Which one is better to use ?
-----------------------------------
Formula 1:
-----------------------------------
mrsja2024 Formula 1 is better approach but if the result should be same as Formula 2 in EVERY situation then you need to include KEEPFILTERS as well, right now it is working because you're not using Group & SalesTerritoryKey columns in the report.
Sales in europe = CALCULATE ( SUM ( Sales[Cost] ), KEEPFILTERS ( 'Region'[Group] = "europe" ), KEEPFILTERS ( 'Region'[SalesTerritoryKey] = 10 ) )It is a best practice to filter only columns and not the whole table.
Use FILTER when you bring columns from different tables and have to filter out some combinations.
2 Replies
- AntrikshSharma
Community Champion
mrsja2024 Formula 1 is better approach but if the result should be same as Formula 2 in EVERY situation then you need to include KEEPFILTERS as well, right now it is working because you're not using Group & SalesTerritoryKey columns in the report.
Sales in europe = CALCULATE ( SUM ( Sales[Cost] ), KEEPFILTERS ( 'Region'[Group] = "europe" ), KEEPFILTERS ( 'Region'[SalesTerritoryKey] = 10 ) )It is a best practice to filter only columns and not the whole table.
Use FILTER when you bring columns from different tables and have to filter out some combinations.
- AnonymousNot applicable
These three pics are self explanatory for when, where and how to use filter function.