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 is a software engineer, LinkedIn Learning instructor and STEM ambassador.

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.

In her time at endjin, she has written many blog posts covering a huge range of topics, including deconstructing Rx operators and mental well-being and managing remote working.

Carmel's first LinkedIn Learning course on how to prepare for the Az-204 exam - developing solutions for Microsoft Azure - is due for release next month. And over the last couple of years she has also spoken at NDC, APISpecs and SQLBits. These talks covered a range of topics, from reactive big-data processing to secure Azure architectures.

She is also passionate about diversity and inclusivity in tech. She is 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.