Introduction

Power BI comes with the powerful formula language Data Analysis Expression (DAX) which allows the implementation of custom calculations. There are numerous operators and functions available in DAX. One of the most important DAX functions is the CALCULATE function. The CALCULATE function enables dynamic aggregations based on specific criteria. In this tutorial, we will explore the CALCULATE function and show you how to use it.

Data

The data for this tutorial comes from an Excel file. In the following tutorial, we explain how to import Data from an Excel file into Power BI:

Power BI - Import Data from Excel file
Introduction In this tutorial, we want to import Data from a Excel file into Power BI. This can be easily done in the Power BI Desktop interface. Data Source Our data source is the Excel file student. The file contains the following data: Power BI Desktop In the following, we

We have loaded the data into Power BI without executing any transformations. The data looks as follows:

Now, let's explore how the DAX function CALCULATE works and how to use it.

Syntax

The syntax of the CALCULATE function looks as follows:

CALCULATE(<expression>, <filter1>, <filter2>, ...)

Let's look at the components in detail:

<expression> The expression to be evaluated.
<filter1>, <filter2> Filter arguments that modify the context in which the expression is evaluated.

Example

Now, let's perform an example calculation with the CALCULATE function. In our example, we want to calculate the total credit points of students born in the year 2000.

First, we create a new measure.

We name the measure "Measure Total Creditpoints Birthyear 2000" and enter the DAX code.

You can view this post with the tier: Academy Membership

Join academy now to read the post and get access to the full library of premium posts for academy members only.

Join Academy Already have an account? Sign In