Calculation Basics Advanced Calculations: DAX To The MAXX Paul Turley
Calculation Basics Advanced Calculations: DAX To The MAXX Paul Turley
Calculation Basics Advanced Calculations: DAX To The MAXX Paul Turley
Advanced Calculations
DAX to the MAXX()
DAX
Excel
functions
SQL DAX
MDX
© 2017 Intelligent Business LLC, intelligentbiz.net 3
Learning DAX ABS
ACOS
DATESMTD
DATESQTD
LEFT
LEN
REPT
RIGHT
ACOSH DATESYTD LN ROLLUP
ACOT DATEVALUE LOG ROLLUPADDISSUBTOTAL
ACOTH DAY LOG10 ROLLUPGROUP
ADDCOLUMNS DEGREES LOOKUPVALUE ROLLUPISSUBTOTAL
ADDMISSINGITEMS DISTINCT LOWER ROUND
ALL DISTINCTCOUNT MAX ROUNDDOWN
ALLEXCEPT DIVIDE MAXA ROUNDUP
ALLNOBLANKROW EARLIER MAXX ROW
ALLSELECTED EARLIEST MEDIAN SAMEPERIODLASTYEAR
AND EDATE MEDIANX SAMPLE
ASIN ENDOFMONTH MID SEARCH
ASINH ENDOFQUARTER MIN SECOND
ATAN ENDOFYEAR MINA SELECTCOLUMNS
ATANH EOMONTH MINUTE SIGN
AVERAGE EVEN MINX SIN
AVERAGEA EXACT MOD SINH
AVERAGEX EXCEPT MONTH SQRT
BETA.DIST EXP MROUND SQRTPI
BETA.INV EXPON.DIST NATURALINNERJOIN STARTOFMONTH
BLANK FACT NATURALLEFTOUTERJOIN STARTOFQUARTER
CALCULATE FILTER NEXTDAY STARTOFYEAR
CALCULATETABLE FILTERS NEXTMONTH STDEV.P
CALENDAR FIND NEXTQUARTER STDEV.S
CALENDARAUTO FIRSTDATE NEXTYEAR STDEVX.P
CEILING FIRSTNONBLANK NOT STDEVX.S
CHISQ.DIST FIXED NOW SUBSTITUTE
CHISQ.DIST.RT FLOOR ODD SUBSTITUTEWITHINDEX
CHISQ.INV FORMAT OPENINGBALANCEMONTH SUM
CHISQ.INV.RT GCD OPENINGBALANCEQUARTER SUMMARIZE
CLOSINGBALANCEMONTH GENERATE OPENINGBALANCEYEAR SUMMARIZECOLUMNS
CLOSINGBALANCEQUARTER GENERATEALL OR SUMX
CLOSINGBALANCEYEAR GEOMEAN PARALLELPERIOD SWITCH
functions CONTAINS
COS
COSH
IFERROR
IGNORE
INT
PERCENTILE.INC
PERCENTILEX.EXC
PERCENTILEX.INC
TOTALMTD
TOTALQTD
TOTALYTD
COT INTERSECT PERMUT TRIM
#%@!
Elegantly complex
Deceptively simple
Most calculations
© 2017 Intelligent Business LLC, intelligentbiz.net 5
What to Learn
Examples of some important DAX functions & concepts
Beyond the basics, specific functions are useful in different business scenarios
There or than 250 DAX functions and more added with each major release
CONTAINS()
SWITCH() SUMX()
ISBLANK()
DATEDIFF()
MEASURES
EVALUATE
CALCULATE() HASONEVALUE()
EOMONTH()
DIVIDE()
FILTER() SUMMARIZE()
PERVIOUSMONTH()
TODAY()
FIRSTNONBLANK() TOTALMTD()
SAMEPERIODLASTYEAR() DATESMTD()
© 2017 Intelligent Business LLC, intelligentbiz.net 6
Important Concepts
defined
• Model designer maintains control
• Default behavior may not always be right
Some DATE()
TIME()
DATESMTD()
TOTALMTD()
FILTER()
VALUES()
ISBLANK()
ISERROR()
IF()
AND, &&, AND()
SUM()
AVERAGE()
SUMX()
AVERAGEX()
examples TODAY()
NOW()
PERVIOUSMONTH()
SAMEPERIODLASTYEAR()
ALL()
CALCULATE()
CONTAINS()
HASONEVALUE()
OR, ||, OR()
SWITCH()
DIVIDE() RANKX()
PERCENTILE()
DATEDIFF() DATESINPERIOD() TRUE()
EOMONTH()
This measure calculates the average Weather Delay only for those flights where there was a delay (over 0 minutes)
CALCULATE() parameters
(if CALCULATE is part of the function)
Mixed totals: Operates on one row at a time, accumulating the result of the prior iteration
• SUMX
• AVERAGEX
• MINX
• MAXX
• COUNTX
• COUNTAX
• PRODUCTX
• CONCATENATEX
e [email protected]
b SqlServerBi.blog
l linkedin.com/in/pturley
t @paul_turley