# Evaluation Context In DAX Calculations

In this tutorial, we’ll learn about evaluation context in DAX.

Evaluation or initial context is the environment from which your dynamic calculation is based from.

It’s important to understand how evaluation context works and how it affects your DAX calculation. So in the next section, I want to show you the different ways to create the evaluation or initial context.

## Creating Evaluation Or Initial Context In DAX

First, you need to have a Date slicer and City filter in your table to achieve dynamic data.

Thereâ€™s always an initial context that you need to be aware of before doing any calculation. You can find the said evaluation context from any location.

In the sample table, the context can be found from the Date slicer or from the City filter. For example, if you select the Christchurch filter, the results in the table will change. If you also adjust the dates from the 1st of January to the 19th of January, you can see that the results changed.

For example, for the 1st of January, the result is 90,074.80 while on the 19th of January, itâ€™s 111,293.70. This proves that evaluation context can really change for every single result in DAX calculations.

To show you another example, letâ€™s turn the existing table into a Total Sales by Date visualization.

When you select or clear a filter or even adjust the time frame, you can get a new result inside the visualization.

The key thing to note is that the formula that we are using in this table and visualization doesn’t change. It is exactly the same formula.

In Excel, every single formula you see will be slightly different because the cell references will be different. In Power BI, the formula stays exactly the same. What changes the result is the context or the environment in which it is evaluated. This applies for every measure you create.

Every calculation you do within Power BI has an initial context that you need to understand. Before you look at any individual result, you need to understand the current context of that calculation.

If you didn’t know what was selected in the city slicer, you would be looking at this visualization and know that this is the Total Sales by Date. But what kind of Total Sales is it?

In the example below, you’ll know that the total sales displayed in the visualization are from Hamilton based on the slicer.

## Relationship Between Context And Data Model

Understanding how this context works is a crucial part of learning and understanding DAX – because this is as easy as it gets. You can then start manipulating the context within formulas and start doing some advanced analysis.

Hopefully, you’re also starting to see how important the model is because the context is directly created by the relationships among your tables.

The city slicer that we are selecting is from the Regions table while the calculation of Total Sales is in the Sales table.

This is called filter propagation.

Filters propagate down the relationship through the arrows and they head towards the many sides on the fact table, which is the Sales table in this case.

You can do as many of these things at any one time because the context can come from one lookup table and another lookup table. And then we could layer even more and create more context. We just have to understand what the initial context of the calculation is.

## Conclusion

Filters and slicers are basic ways to create evaluation context in your DAX calculations.

I hope you understand just how important evaluation (initial) context is. If you want to do an advanced analysis later on, youâ€™ll have to change the context within your formulas.

Cheers!

Sam

Sam McKay, CFA
Sam is Enterprise DNA's CEO & Founder. He helps individuals and organizations develop data driven cultures and create enterprise value by delivering business intelligence training and education.

## Power BI Report Examples And Best Practices – Part 1

In today's post, I'd like to present some Power BI report examples and best practices. In my own Power...

## Power BI Python Tutorial: How To Translate Texts

This blog will demonstrate how to perform language or text translation using Python and pipe it over...

## Measure In Power BI: Optimization Tips And Techniques

In this tutorial, youâ€™ll learn how to optimize a measure in Power BI. Optimizing measures in your...

## How To Use Power Query Row And Column Selection

This tutorial will discuss how to use selection and projection inside the Power Query Editor. Selection...

## Use Tabular Editor To Create Calculation Groups In Power BI

Today's blog post will give you an introduction to calculation groups. I'll try to answer four basic...

## Effective Data Storytelling: Asking The Right Questions

To ensure that we have a good story to tell, effective data storytelling by asking the right questions...

## The Top 5 Power BI Alternatives in 2023

Power BI has established itself as a powerful business analytics platform, offering a wide range of...

## Turning Calendar Type Layout Into Tabular Format In Power BI Using Query Editor

Analyzing the data that we have can be difficult if it is not correctly arranged. In this tutorial, I...

## Create A Lookup Table From Subtotals: Optimization In Power BI

In this tutorial, weâ€™ll go through a technique that will create a lookup table from subtotals using the...

## Showing Difference Between Sales And Budgets To Date – Forecasting In Power BI

The topic that I'm going to discuss in this tutorial was part of a full-hour workshop on budgeting and...

## How To Merge Queries In Power BI

Merging is another powerful transformation to optimize our...

## Unpacking The Evolution Of Power BI – From Launch to Now

Microsoft Power BI is a dynamic business intelligence platform that has revolutionized the way...