DAX and Power BI Training - 005 DAX Level 4
-
Upload
will-harvey -
Category
Technology
-
view
470 -
download
26
Transcript of DAX and Power BI Training - 005 DAX Level 4
DAX Level 4
YTD
March
YTD
March
YTD
March
CALCULATE() with ALL() and FILTER()
2 Types of Filters:
Simple Filters & Advanced Filters
CALCULATE([measure], <filter1>, <filter2>, … <filterN>)
2 Types of Filters:
Simple Filters & Advanced Filters
CALCULATE([measure], <filter1>, <filter2>, … <filterN>)
ALL()
ALL('table' or 'table'[column])
#1 - Pick a cell in the pivot
#1 - Pick a cell in the pivot
#2 – Got DAX Filters?
Sales All Customers = CALCULATE([Sales],ALL('Customers'))
Sales All Customers = CALCULATE([Sales],ALL('Customers'))
Sales All Customers = CALCULATE([Sales],ALL('Customers'))
Sales All Customers = CALCULATE([Sales],ALL('Customers'))
#3 - Picture filters reducing data in the model
#4 - After filtering, apply math
#4 - After filtering, apply math
#4 - After filtering, apply math
ALL()Qty % of Vendors
FILTER()
FILTER('table',<any filter>)
FILTER()Non-Diversified Suppliers
ALL() and FILTER()
ALL() and FILTER()On Contract YTDOn Contract LYTD
DAX Formatterhttp://www.daxformatter.com/
Tip - DAX Step through formula
Sales YTD :=CALCULATE (
[Sales],FILTER (
ALL ( 'Calendar' ),AND (
Calendar[Year] = MAX ( Calendar[Year] ),Calendar[Date] <= MAX ( Calendar[Date] )
))
)
Sales YTD :=CALCULATE (
[Sales],FILTER (
,AND (
Calendar[Year] = MAX ( Calendar[Year] ),Calendar[Date] <= MAX ( Calendar[Date] )
))
)
Date Year
1/1/2014 2014
1/2/2014 2014
… …
12/30/2018 2018
12/31/2018 2018
Sales YTD :=CALCULATE (
[Sales],FILTER (
,AND (
Calendar[Year] = 2016,Calendar[Date] <= “2/29/2016”
))
)
Date Year
1/1/2014 2014
1/2/2014 2014
… …
12/30/2018 2018
12/31/2018 2018
Sales YTD :=CALCULATE (
[Sales],FILTER (
,AND (
True,True
))
)
Date Year
1/1/2014 2014
1/2/2014 2014
… …
12/30/2018 2018
12/31/2018 2018
Sales YTD :=CALCULATE (
[Sales],FILTER (
,True)
))
Date Year
1/1/2014 2014
1/2/2014 2014
… …
12/30/2018 2018
12/31/2018 2018
Sales YTD :=CALCULATE (
[Sales],
)
Date Year
1/1/2016 2016
1/2/2016 2016
… …
2/28/2016 2016
2/29/2016 2016
Sales YTD :=CALCULATE (
[Sales],
)
Date Year
1/1/2016 2016
1/2/2016 2016
… …
2/28/2016 2016
2/29/2016 2016
Filter the Sales table through relationship in the model.
Brand Customer Item Division Requested Ship Date Gross Line Amount
Brand 8 Customer 2 Item No 350 Division 2 1/1/2014 5.49
Brand 8 Customer 2 Item No 350 Division 2 1/2/2014 7.37
… … … … … …
Brand 8 Customer 2 Item No 350 Division 2 4/23/2016 8.45
Brand 8 Customer 2 Item No 350 Division 2 4/24/2016 3.45
Sales YTD :=$9,779,779
Brand Customer Item Division Requested Ship Date Gross Line Amount
Brand 8 Customer 2 Item No 350 Division 2 1/1/2016 3.56
Brand 8 Customer 2 Item No 350 Division 2 1/2/2016 5.07
… … … … … …
Brand 8 Customer 2 Item No 350 Division 2 2/28/2016 4.22
Brand 8 Customer 2 Item No 350 Division 2 2/29/2016 5.8
Do the math and return the value to the cell in the pivot table.
Exercise• ALL()
• Qty % of Vendors
• FILTER()• Non-Diversified Suppliers
• ALL() and FILTER()• On Contract YTD
• On Contract LYTD
DAX Books
Homework• Finish creating metrics
• Explore a real world dataset with Power Query
• Practice your transformation skills by turning the data into something useful
• Share your Power Query experience with Steve
Next Week• Beginner Power Pivot
• Logical Functions IF() and SWITCH()
• Time Intelligence Functions
• Budget vs Actual or Benchmark vs Actual