Row Context and Filter Context in Power BI
Row Context and Filter Context are two important concepts that finds how data is calculated and displayed in our reports. Understanding these contexts is important for using Data Analysis Expressions (DAX) effectively.
- Row Context focuses on calculations for each individual row.
- Filter Context controls which data is included or excluded based on applied filters.
In this article, we will understand these concepts so that we can apply them effectively in our own Power BI projects.
Understanding Row Context and Filter Context in DAX
Data Analysis Expressions (DAX) is used in Power BI to create calculated columns, measures and custom tables. We manage row context with functions like SUMX which iterate row by row for calculations. Filter Context is controlled by functions like CALCULATE modifies the filter criteria to find the data subset for calculations. These contexts enable dynamic and accurate data analysis in Power BI.
What is Row Context in Power BI?
Row Context refers to the calculation and evaluation of values for each individual row in a table using the values from that specific row's columns.
For example consider a Financial Data table with Units Sold and Price per Unit columns. To calculate Total Price, the formula would be:
Total Price = (Price per Unit) * (Units Sold)
In this case, Row Context ensures that the calculation is performed for each row i.e multiplying the Price per Unit by the Units Sold for that particular row.
What is Filter Context in Power BI?
Filter Context refers to the set of filters applied to the data before performing calculations in Power BI. It defines which subset of data is included or excluded based on the active filters which dynamically adjust calculations.
For example, using the Total Price measure if a filter is applied to show data for a specific product, the filter context updates to include only the data related to that product. Total Price will then be calculated based on this filtered data which provides insights specific to the selected product.
Row Context vs Filter Context
Row Context | Filter Context |
---|---|
Calculation is done row-by-row, considering individual rows. | Calculation is based on a subset of rows calculated by active filters. |
Applies to one row at a time. | Applies to multiple rows, filtered dynamically based on user input. |
Evaluates values in each row using data from that row’s columns. | Modifies the data set by including/excluding rows based on filters. |
Calculating Total Price for each row in a financial table. | Calculating Total Price for data filtered by product category. |
SUMX, FILTER (used row-by-row) | CALCULATE, ALL (modifies filter context) |
Row Context and Filter Context in DAX Example
Now let us see an example of Row Context and Filter Context in Power BI.
Row Context in DAX Example
In this example, let's say we have a dataset with the following columns:
- Number of Units Sold
- Cost Price per Unit
- Selling Price per Unit
We can calculate the Cost Price, Selling Price and Profit for each product using Row Context.
Step 1: Cost Price Calculation:
To calculate the Cost Price for each product, the formula is:

Step 2: Selling Price Calculation:
To calculate the Selling Price for each product, the formula is:

Step 3: Profit Calculation:
To calculate the Profit for each product, subtract the Cost Price from the Selling Price:

Using Row Context these calculations are performed for each row individually, taking the values of the Cost Price per Unit, Selling Price per Unit and Number of Units Sold from that specific row to find the Profit for that product.
Note: Here SUMX is used instead to SUM as the Selling Price, Cost Price and Profit are, calculated for each row. SUMX iterates row by row the formula inside its function whereas SUM would have calculated the aggregate of values for the whole column.
Demonstration of Row Context on the Dashboard with the help of Profit Measure
Now, let’s create a dashboard using the Profit measure and see how Total Profit is calculated for each row as well as for the entire column.




From the above Figures, it can be seen that Total Profit is calculated both row-wise as well as column-wise.
Filter Context in DAX Example
By utilizing Filter Context, we can show how the Total Profit changes both row-wise and column-wise as the active filter conditions change. This highlights the dynamic nature of the context and how it affects data calculations in Power BI.


.png)

From the above figures, it can be observed that the Total Profit has changed after applying the filter conditions. Since the Region is set to Asia only countries within Asia whose Sales Channel is Offline are displayed. Total Profit for each country under Asia is shown and the profit for each year in the Asia region with the Offline sales channel is visible. Other regions in the Region and Year tables are excluded restricting their visibility. Total Profit of 139.34M corresponds to Asia with Offline sales.
Note: When both Row Context and Filter Context are used together, Filter Context is applied first. Row Context is then executed based on the filtered data. This order of operations ensures that the calculation is done with the correct subset of data.
CALCULATE Function in Filter Context
CALCULATE function in DAX is used to modify the Filter Context. When using CALCULATE, it can overwrite any internal filters which helps in applying only the filters specified in the function. External filters however, will still remain in effect.
Example of CALCULATE Function
Let’s create a measure called Asia Products which calculates the Total Number of Units Sold in the Asia region, regardless of any other region filters that may be applied. Here the internal filter will be set to Region = Asia.
Step 1: Calculation of Total Number of Units Sold in Asia with CALCULATE Function
The formula to calculate Total Number of Units Sold in Asia is:

Step 2: Demonstration of CALCULATE Function on the Dashboard
Now let us design a dashboard with the measure calculated.

Here, with the help of the CALCULATE function, Total Number of Units Sold with respect to Region = Asia is calculated. As seen in the Asia Products column, the total number of units sold in Asia is displayed for all rows regardless of any other Region filters. This means that even if other Region filters were applied elsewhere in the report, they are overwritten by the Region = Asia filter specified in the CALCULATE function. Therefore, the calculation will always show the total units sold in Asia, unaffected by other region-related filters.


Thus Total Number of Units Sold in Asia changes only when external filters like Sales_Channel and Order_Priority are modified. The CALCULATE function overrides the internal Region = Asia filter but does not affect external filters which continue to impact the result.
By understanding Row and Filter Context we can create more dynamic and accurate Power BI reports that adapt to user interactions which provides deeper insights and a better overall analysis experience.