0% found this document useful (0 votes)
11 views2 pages

Calculate Filter Explanation

Uploaded by

mohameddsayed32
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

Calculate Filter Explanation

Uploaded by

mohameddsayed32
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Explanation of CALCULATE and FILTER Functions

1. CALCULATE Function

The CALCULATE function is used to modify the context in which a calculation is performed. It allows you to apply filters

to a calculation, changing the way data is aggregated or computed.

Syntax:

CALCULATE(<expression>, <filter1>, <filter2>, ...)

- <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'.

TotalSalesWest = CALCULATE(SUM(Sales[Amount]), Sales[Region] = '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

filter rows before performing calculations.

Syntax:

FILTER(<table>, <condition>)
- <table>: The table you want to filter.

- <condition>: The condition that determines which rows are kept.

Example:

If you wanted to create a new table that only includes sales greater than $500:

HighValueSales = FILTER(Sales, Sales[Amount] > 500)

3. Using CALCULATE with FILTER

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)

Here's what happens:

- FILTER(Sales, Sales[Region] = 'West' && Sales[Amount] > 500) creates a new table with only the rows where the

region is 'West' and the sales amount is greater than $500.

- CALCULATE then sums up the amounts in this filtered table.

Summary:

- CALCULATE changes the context of a calculation by applying filters.

- FILTER creates a new table based on a condition, which can be used inside CALCULATE to refine your calculations.

You might also like