In my last blog I ran through filter contexts, which are one half of the story around evaluation contexts. I said last time that whenever any formula is evaluated, it is evaluated in an evaluation context. We saw that this evaluation context can include a filter context, which dictates what rows in a table an expression is run over.
A row context is in some ways a specific example of this, but it only applies in iterative situations. For example, in Power BI you can create a new “calculated column” in a table.
So, if we return to our previous example:
And we wanted an additional column which indicates whether or not a person had children, we could do this via a calculated column:
This expression is evaluated for each row in the table to produce the following output:
(This is the table view in Power BI)
The way this works is that it iteratively evaluates
Has children for each row of the table. At each iteration, the evaluation will have a row context. So, for the first iteration, the row context will be the first row, then the second, etc.
Row contexts just signify the “currently selected” row as we go through any iteration. Unlike filter contexts, they cannot be created by the user, they are purely used during iteration to provide the formula with the context it needs in order to do the evaluation.
These are used in any iterative process in DAX, and we will see some more examples of this as we continue.
Now that we have an understanding of the contexts in which formulae are evaluated, it’s time to look at some specific examples…