Calculate Filter Explanation
Calculate Filter Explanation
1. CALCULATE Function
The CALCULATE function is used to modify the context in which a calculation is performed. It allows you to apply filters
Syntax:
- <expression>: This is the calculation you want to perform, like a sum, average, or any other measure.
- <filter>: These are the filters you want to apply to the data before the calculation is done.
Example:
Imagine you have a table of sales data, and you want to calculate the total sales for a specific region, like 'West'.
Here, CALCULATE modifies the context of the sum by filtering the data to only include rows where the region is 'West'.
2. FILTER Function
The FILTER function creates a new table based on a condition. It is often used within CALCULATE or other functions to
Syntax:
FILTER(<table>, <condition>)
- <table>: The table you want to filter.
Example:
If you wanted to create a new table that only includes sales greater than $500:
You can combine CALCULATE with FILTER to perform more complex calculations.
Example:
Let's say you want to calculate the total sales for the 'West' region, but only for sales greater than $500:
TotalHighValueSalesWest = CALCULATE(
SUM(Sales[Amount]),
- FILTER(Sales, Sales[Region] = 'West' && Sales[Amount] > 500) creates a new table with only the rows where the
Summary:
- FILTER creates a new table based on a condition, which can be used inside CALCULATE to refine your calculations.