Quantcast
Channel: Microsoft Dynamics 365 Community
Viewing all articles
Browse latest Browse all 64797

Powerful DAX CALCULATE() Function

$
0
0

The CALCULATE function in DAX is the magic key for many calculations we can do in PowerPivot.

Below is the syntax:

CALCULATE( , , … )

The expression that we put in the first parameter has to be evaluated to return the result (i.e. a value, not a table). For this reason, the expression is usually an aggregation function like SUM, MIN, MAX, COUNTROWS and so on.

This expression is evaluated in a context that is modified by the filters. A key point is that these filters can both enlarge and restrict the current context of evaluation. Let’s try to understand what it means by considering a few examples.

The following data model we have imported in PowerPivot named ‘Contract’ & ‘Project’

Scenario 1
Compare Contract & Project data model on YearMonth Column and take sum of multiple records of revenue column of Project data model into Contract data model
Project data model has StartYM & StartRevenue Column as shown below

Calculate_1

And Contract data model has YM column, using Project data model StartYM, StartRevenue columns & Contract data model YM column, here we have derived StartR column with the help of Calculate() DAX function as shown below

Calculate_2

Formula is
=calculate(sum(Project[StartRevenue]),filter(project,Project[StartYM]=Contract[YM]))
Scenario 2
Calculate running total of ToDo column in ‘Contract-ToDo’ data model on basis of YearMonth column as shown below

Calculate_3

Formula is
=calculate(sum(‘Contract-ToDo'[ToDo]),filter(‘Contract-ToDo’,’Contract-ToDo'[YearMonth]


Viewing all articles
Browse latest Browse all 64797

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>