Skip to content
Carmel Eve By Carmel Eve Software Engineer I
Learning DAX and Power BI – Row Contexts

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:

View over data showing Name, City, DoB and Number of Children.

And we wanted an additional column which indicates whether or not a person had children, we could do this via a calculated column:

Showing calculation for calculated column.

This expression is evaluated for each row in the table to produce the following output:

Showing additional column in model.

(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

Carmel Eve

Software Engineer I

Carmel Eve

Carmel has recently graduated from our apprenticeship scheme.

Over the past four years she has been focused on delivering cloud-first solutions to a variety of problems. These have ranged from highly-performant serverless architectures, to web applications, to reporting and insight pipelines and data analytics engines. She has been involved in every aspect of the solutions built, from deployment, to data structures, to analysis, querying and UI, as well as non-functional concerns such as security and performance.

Throughout her apprenticeship, she has written many blogs, covering a huge range of topics. She has also given multiple talks focused on serverless architectures. The talks highlighted the benefits of a serverless approach, and delved into how to optimise the solutions in terms of performance and cost.

She is also passionate about diversity and inclusivity in tech. Last year, she became a STEM ambassador in her local community and is taking part in a local mentorship scheme. Through this work she hopes to be a part of positive change in the industry.

Carmel won "Apprentice Engineer of the Year" at the Computing Rising Star Awards 2019.