2. @ClubPowerBI @aosComm @GUSS_FRANCEPower Saturday 2019
3 communautés pour partager,
échanger et apprendre
Power BI, Data, IA, Power Platform, Office 365, SharePoint, etc.
4. @ClubPowerBI @aosComm @GUSS_FRANCEPower Saturday 2019
❖Senior Consultant Business Intelligence,
IT-Logix AG, Bern / Zurich
❖More than 25 years in Data Analytics & Reporting
❖Co-Leader Power BI PUG Switzerland
❖Power BI & Excel Speaker
❖LinkedIn Trainer, Blog Author
❖
Who I am….
5. @ClubPowerBI @aosComm @GUSS_FRANCEPower Saturday 2019
Who are the participants?
• BI / Reporting Professional?
• Business User (Controlling / Finance, Marketing, others?)
• Experience in DAX?
- none, little, seasoned, Ninja (aka SQLBI)?
6. @ClubPowerBI @aosComm @GUSS_FRANCEPower Saturday 2019
❖ Introduction
❖ Evaluation Context – explore how DAX works
❖ Introducing CALCULATE()
❖ Working with Filter conditions from tables / columns:
- Add & Update Filters
- Ignore Filters
❖ Filtering with Measures
❖ Conclusion & Questions
Agenda
8. @ClubPowerBI @aosComm @GUSS_FRANCEPower Saturday 2019
Evaluation Context - how DAX works
F
1. Filter evaluation ("initial filter context")
=> Report Filter, Page Filter, Visual Filter,
Slicers, Row Header, Column Header
C
2. CALCULATE() ("explicit" filters)
sets, updates or ignores filters
R
3. Relationships
propagate relations from dimensions to facts (in filter direction)
A
4. Arithmetic
calculating the result according to the formula (e.g. SUM)
Filter
Context
https://www.powerbi-pro.com/en/how-dax-calculates-values/
10. @ClubPowerBI @aosComm @GUSS_FRANCEPower Saturday 2019
2. Calculate – explicit filter conditions
❖Sales = Sum(Sales[SalesAmount])
=> In this example, there is no explicit filter set
❖Sales = CALCULATE ([Sales];
Products[Color] = "black")
=> explicit filter for products table is set
❖more later…..
12. @ClubPowerBI @aosComm @GUSS_FRANCEPower Saturday 2019
4. Doing the math
❖Sales = Sum(Sales[SalesAmount])
=> e.g. summing up the surviving rows in the
fact table
❖Sales = CALCULATE ([Sales];
Products[Color] = "black")
=> e.g. summing up the surviving rows in the
fact table
13. @ClubPowerBI @aosComm @GUSS_FRANCEPower Saturday 2019
❖Corresponds approximately to the SUMIFS()
function in Excel – but it is more powerful
❖The best friend of every DAX user
❖The only function that can change the
initial filter context!
Introducing CALCULATE()
14. @ClubPowerBI @aosComm @GUSS_FRANCEPower Saturday 2019
Calculate Function
https://dax.guide/calculate/
• The second set of arguments, i.e. the “Filter arguments,” are evaluated and applied first
• Then the expression is evaluated under new “Filter Context"
15. @ClubPowerBI @aosComm @GUSS_FRANCEPower Saturday 2019
❖ If there is no existing filter
context, a new filter is added by
the filter parameter
❖ Otherwise, the filter parameter
updates the existing filter context
Two Rules of CALCULATE()
21. @ClubPowerBI @aosComm @GUSS_FRANCEPower Saturday 2019
Comparison options
CALCULATE() expects filter conditions in the form of
❖ Table[column] = condition (e.g. products[color]="red")
or similar
❖ To the left of the comparison operator
(=, <, >, <=, >=, <>)
a column from a table must be listed.
❖ No measure may be used to the right
of the comparison operator either.
22. @ClubPowerBI @aosComm @GUSS_FRANCEPower Saturday 2019
Comparison options with FILTER()
The following comparison options are allowed with FILTER():
❖ Table[Column] = [Measure]
❖ Table[Column] = Table[Column]
❖ [Measure] = [Measure2]
❖ AND:
<TRUE/FALSE expression1> && < TRUE/FALSE expression2>
❖ OR:
<true/FALSE expression1> || <true/FALSE expression2>
25. @ClubPowerBI @aosComm @GUSS_FRANCEPower Saturday 2019
❖CALCULATE() is a mighty weapon
❖Always take a look at the filter context
❖use DAX Studio or a calculated table if
you get stuck
Take Aways
26. @ClubPowerBI @aosComm @GUSS_FRANCEPower Saturday 2019
Hans Peter Pfister
h.p.pfister@powerbi-pro.com
www.powerbi-pro.com
@hp_pfister
www.linkedin.com/in/hans-peter-pfister
Contact me!
29. @ClubPowerBI @aosComm @GUSS_FRANCEPower Saturday 2019
The European SharePoint, Office 365 & Azure Conference
4 Days 2,500 Delegates 150+ Sessions 120 Speakers
Use code ESPC19SPSP for 10% discount on all tickets
www.sharepointeurope.com