dax best practices - power bi user group
TRANSCRIPT
PowerBIWorldTour.com #PBIWorldTour
DAX Best PracticesDaniil Maslyuk
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
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
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
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/
PowerBIWorldTour.com #PBIWorldTour
Best practice: learn theory!
• DAX is not SQL
• DAX is not MDX
• DAX is not Excel formula language
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
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
PowerBIWorldTour.com #PBIWorldTour
Best practice: filter columns, not tables!
• Do not filter whole tables
• Filter columns
• Filter selected columns
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
Don’t forget to join your local PUG to enjoy year-round networking and learning.