Concept Breakdown
The `FILTER` function in DAX is a table function that returns a table. It takes two arguments: a table and a filter expression. For each row in the input table, the filter expression is evaluated. Only rows for which the expression evaluates to TRUE are included in the resulting table. When `FILTER` is nested within an iterator function (e.g., `SUMX`, `AVERAGEX`, `COUNTX`), it first creates a filtered table based on the specified condition. The outer iterator then performs its calculations row-by-row over this newly filtered table, allowing for flexible conditional aggregations.
What You Will Learn
Understand when to use FILTER, AVERAGEX in a Power BI model.
Practice the concept inside a real PBIX report rather than only reading syntax.
Complete a beginner-level task and verify the result with a hidden answer check.
Practice in Power BI
The starter PBIX link has not been attached yet. The student workflow is ready for the admin to connect the file.
Download and unzip the provided file "Tallest Buildings - Filter Function.pbix".
Open the "Tallest Buildings - Filter Function.pbix" file in Power BI Desktop. You will see a chart showing the average number of floors for buildings in different countries.
Create a new measure named "Average Floors Before 2010" which calculates the average number of floors for buildings that opened before the year 2010, using a combination of `AVERAGEX` and `FILTER`.
Create another new measure named "Average Floors Since 2010" which calculates the average number of floors for buildings that opened since (including) the year 2010, also using `AVERAGEX` and `FILTER`.
Add both newly created measures to the existing chart.
Observe the updated chart, which should now display the average number of floors for both categories alongside the original average.
Save and close the report.
Starter DAX
New Measure =
AVERAGEX(
FILTER(
'YourTable',
'YourTable'[YourYearColumn] < 2010
),
'YourTable'[ValueColumn]
)Expected Outcome
The chart will display the average number of floors per country, showing two new series: one representing buildings opened before 2010 and another for buildings opened since 2010.