dax best practices - power bi user group
TRANSCRIPT
![Page 1: DAX Best Practices - Power BI User Group](https://reader031.vdocuments.us/reader031/viewer/2022012213/61df64444b7fcc51d3657176/html5/thumbnails/1.jpg)
PowerBIWorldTour.com #PBIWorldTour
DAX Best PracticesDaniil Maslyuk
![Page 2: DAX Best Practices - Power BI User Group](https://reader031.vdocuments.us/reader031/viewer/2022012213/61df64444b7fcc51d3657176/html5/thumbnails/2.jpg)
PowerBIWorldTour.com #PBIWorldTour
DAX Best Practices
This is a very technical session!
Today, we will be
• Reviewing examples of DAX code from the real world in demos
• Spotting issues
• Formulating best practices
![Page 3: DAX Best Practices - Power BI User Group](https://reader031.vdocuments.us/reader031/viewer/2022012213/61df64444b7fcc51d3657176/html5/thumbnails/3.jpg)
PowerBIWorldTour.com #PBIWorldTour
Session Agenda
• Introduction
• Demo 1: readability
• Demo 2: constructs necessity
• Demo 3: repetitions
• Demo 4: repetitions II
• Demo 5: filtering
• Demo 6: references
![Page 4: DAX Best Practices - Power BI User Group](https://reader031.vdocuments.us/reader031/viewer/2022012213/61df64444b7fcc51d3657176/html5/thumbnails/4.jpg)
PowerBIWorldTour.com #PBIWorldTour
Daniil Maslyuk• Consultant at Analytics8
• Author of the official Power BI Exam Ref (70-778) book
• Technical editor of The Definitive Guide to DAX, 2nd edition
• Blog: xxlbi.com
• Twitter: @DMaslyuk
![Page 6: DAX Best Practices - Power BI User Group](https://reader031.vdocuments.us/reader031/viewer/2022012213/61df64444b7fcc51d3657176/html5/thumbnails/6.jpg)
PowerBIWorldTour.com #PBIWorldTour
Best practice: format your code!
• Use DAX Formatter• www.daxformatter.com
• Also part of DAX Studio and Tabular Editor
• Use DAX formula bar keyboard shortcuts• https://xxlbi.com/blog/dax-formula-bar-keyboard-shortcuts-in-power-bi-
desktop/
![Page 8: DAX Best Practices - Power BI User Group](https://reader031.vdocuments.us/reader031/viewer/2022012213/61df64444b7fcc51d3657176/html5/thumbnails/8.jpg)
PowerBIWorldTour.com #PBIWorldTour
Best practice: learn theory!
• DAX is not SQL
• DAX is not MDX
• DAX is not Excel formula language
![Page 10: DAX Best Practices - Power BI User Group](https://reader031.vdocuments.us/reader031/viewer/2022012213/61df64444b7fcc51d3657176/html5/thumbnails/10.jpg)
PowerBIWorldTour.com #PBIWorldTour
Best practice: reuse measures!
• Split your calculations in smaller blocks
• Reuse measures instead of writing the same code
• DRY (don’t repeat yourself) still applies
![Page 12: DAX Best Practices - Power BI User Group](https://reader031.vdocuments.us/reader031/viewer/2022012213/61df64444b7fcc51d3657176/html5/thumbnails/12.jpg)
PowerBIWorldTour.com #PBIWorldTour
Best practice: use variables!
• Variables can be used to document your code
• Variables can help you avoid repetition
• Be aware that variables are actually constants
![Page 14: DAX Best Practices - Power BI User Group](https://reader031.vdocuments.us/reader031/viewer/2022012213/61df64444b7fcc51d3657176/html5/thumbnails/14.jpg)
PowerBIWorldTour.com #PBIWorldTour
Best practice: filter columns, not tables!
• Do not filter whole tables
• Filter columns
• Filter selected columns
![Page 16: DAX Best Practices - Power BI User Group](https://reader031.vdocuments.us/reader031/viewer/2022012213/61df64444b7fcc51d3657176/html5/thumbnails/16.jpg)
PowerBIWorldTour.com #PBIWorldTour
Best practice: follow naming conventions!
• Column reference: Table[Column]
• Measure reference: [Measure]
• User-friendly names are the best
• There is no problem with spaces in names
![Page 17: DAX Best Practices - Power BI User Group](https://reader031.vdocuments.us/reader031/viewer/2022012213/61df64444b7fcc51d3657176/html5/thumbnails/17.jpg)
Don’t forget to join your local PUG to enjoy year-round networking and learning.