FROM SQL to DAX
@Anniexu1990
Who I am
• Dan (Annie) Xu
• Business Intelligence Consultant
• MCSA -> MCSE (BI)
• Blog: https://anniexu1990.com
• All social media accounts (including gmail): anniexu1990
BEFORE We BEGIN
Agenda
• Why use DAX
• SQL to DAX – As Querying Language
• Why faster and key techniques
• Query plan and performance tuning
Why use DAX
• The Modeling, and Querying language for SSAS Tabular Models
(PowerBI and Power Pivot - local instance of Analysis Service)
• Excel pivot table, SSMS or SSRS – MDX is the default language against
SSAS models
• More secure and one source of truth - client
• Faster in almost all analytic situations (column store and Vertipaq
compression)
• Another Option to extract and analyze data (replace ETL, customized
measures etc.)
SQL to DAX – As Querying Language
• Select
• Grouping
• Table Joins
• Aggregation
• Filter
• Customized measures
DEMO
Let’s compare the timing
Why faster - Column Store vs. Row Store
http://saphanatutorial.com/column-data-storage-and-row-data-storage-sap-hana/
Why faster - VertiPaq Compression (reduce
memory footprints)
https://www.microsoftpressstore.com/articles/article.aspx?p=2449192&seqNum=3
How to make DAX faster?
Formula Engine vs. Storage Engine
Category Formula Engine Storage Engine
Thread Single - Threaded Multi – Threaded
Cache No Yes
utilization
Performance Check physical plan Check xmSQL queries
Tuning (a textual
representation of SE
query)
Performance Tuning for DAX
“The most important factor of DAX formula speed is data distribution”
• Vertipaq Analyzer
Formula Engine Bottlenecks
• Redundant logic steps
• Long iterations over datacaches
Storage Engine Bottlenecks
• Long Scan time
• Large cardinality
• High frequency of CallbackdataID (a function in Storage Engine communicating back
to formula engine for complicated calculations which disable the cache)
• Large materialization
Appendix List
• Useful Links
• Key Concepts
• Useful Tools for DAX and Tabular Modeling
• My Demo Code
Useful Links
• https://www.sqlbi.com/
• https://powerpivotpro.com
• http://anniexu1990.com
• Book: The Definitive Guide to DAX
Key Concepts
• Column store vs. row store technology
• Vertipaq compression
• Row context vs. filter context
• Formula Engine vs. Storage Engine
Useful Tools for
DAX and Tabular Modeling
• DAXStudio
• Vertipaq Analyzer
• DAX Editor
My Codes used in the demo
• SQL to DAX: Select, Grouping and Table Joins
• SQL to DAX: Filter and Customized Measures