Row Context and Filter Context

There are two types of contexts in DAX: row context and filter context.

a) Row context

Row context refers to the current row that the calculation is being performed on. When we create calculated columns or measures in Power BI, they are evaluated within the context of each row in the dataset. This means that calculations are performed row by row, and the result is based on the values in that specific row. For example, if you have a calculated column that calculates the total sales for each product, the calculation is performed individually for each row of the product table.

Row context is also used when a class of functions, known as iterator functions, are used. Iterator functions provide us with flexibility to create sophisticated summarizations.

DAX

SUM of the number = "MY" & ('Sheet1'[10th Marks]+'Sheet1'[12th Marks])

When the formula is evaluated for each row, the 'Sheet1'[10th Marks] column reference returns the column value for that row.

b) Filter context

Filter context, on the other hand, refers to the set of filters that are applied to the data. These filters can be applied explicitly by the user through slicers, filters, or interactions with visualizations, or they can be implicitly applied based on relationships between tables and selections made in other visualizations. The filter context determines which subset of data is used in the calculations.

Filter context doesn’t exist in place of row context; rather, it applies in addition to row context. For example, to further narrow down the values to include in a calculation, we can apply a filter context, which not only specifies the row context, but also specifies a particular value (filter) in that row context.

For example, the cell highlighted in the following picture has a filter context for country “India”, and Name is equal to “Alia”. This is the reason why its value is different, for example, from the one showing the same country for “Ashish”.

Filter context in Power BI