Row Context vs. Filter Context | Power BI || Belayet Hossain
Belayet Hossain
Data Analyst @ZnZ ? SQL -Power BI -Python-ETL -Excel ? Transforming Data into Insight that Drive Decision
?? 1. Filter Context
Filter context is the context that comes from filters applied to your data. These filters can come from slicers, visuals, or explicitly from DAX expressions that modify what data is visible or considered in a calculation.
How it works:
Example:
You have a table with sales data, and you apply a slicer to show only sales for 2023. This slicer creates a filter context, so only rows related to 2023 are included in the calculation.
Use in DAX:
Visual Example:
?? 2. Row Context
Row context refers to the current row that DAX is evaluating. It’s specific to each individual row, meaning DAX processes calculations on a row-by-row basis when creating calculated columns
How it works:
领英推荐
Example:
If you are calculating the profit margin for each sale in a table, DAX would use the row context to calculate the margin for each individual row.
Use in DAX:
Visual Example:
To calculate profit (Sales - Cost), you use row context to evaluate each row individually.
?? Differences Between Filter Context and Row Context
?? Bringing Them Together
When writing DAX, row context and filter context can interact. For example, CALCULATE() modifies the filter context to change what rows are being considered, while iterating functions like SUMX() introduce a row context to calculate results for each row individually.
#PowerBI #filtercontext #rowcontext