Mainly there are two types of evaluation context in DAX and they are : Filter context & Row context.
The filter context is the set of filters applied to the data model before the evaluation of a DAX expression starts. Filter Context always exist before a DAX expression been evaluated.
Some initial level filters context applied on Power BI report page in form of:-
- Filter through other Visual
- In Matrix visual based on Row and column data fields
- Power BI filters
A Row context is evaluated whenever an expression iterates over a table. Each individual row in a table has its own row context.
A row context exists in either a calculated column or an iterating DAX functions such as SUMX, AVERAGEX, FILTER & ADDCOLUMNS etc.
If you have created a calculated column, the row context consists of the values in each individual row and values in columns that are related to the current row.
To calculate the Total Sales the Qty should be multiplied by the Sales of each category, in a new calculated column TotalSales.
As you know calculated column perform row by row calculation( row context), so you can see the result in below screen shot.
Filter Context and Row Context in same DAX formula
Sample dataset as below:-
Step-1: Create a measure and write below DAX
Total Sales = SUMX( FILTER('Product', 'Product'[Region]="A") , 'Product'[Sales] * 'Product'[Qty])
It is filtering the table for each row where Region is “A” and multiplying sales with quantity.
Step-2: Drag new measure into Table visual to see the final output. It will return the value only for Region “A” with specified condition.
Hope you enjoyed the post. Your valuable feedback, question, or comments about this post are always welcome or you can leave us message on our Contact form , we will revert to you asap.