- Intelligent Cloud Conference...o Download and install DAX Studio •get ready to spend time...

Post on 09-Oct-2020

2 views 0 download

Transcript of - Intelligent Cloud Conference...o Download and install DAX Studio •get ready to spend time...

www.sqlbi.com

DAX Optimization Examples

Alberto Ferrari - SQLBI

Expo Sponsors Event Sponsors

Expo Light Sponsors

We write

BooksWe teach

CoursesWe provide

ConsultingWe are recognized

BI Experts

Remote

Consulting

Power BI/SSAS

Optimization

BI Architectural

Review

On-Site

Consulting

Custom Training

& Mentoring www.sqlbi .com

It all starts this way…

“Would you mind taking a look at

my report? It is slow and I am sure

it will take you no more than a

couple of minutes to fix it”

Agenda

o Optimize a report step-by-step

o in the meantime find some time to:

• Learn the basics of useful tools to measure performance• Understand the way DAX solves your queries• Learn about Formula Engine and Storage Engine• Measure performance and detect bottlenecks• Reproduce the issue and measure it again to obtain better

findings• Solve the problems, one at a time

• No “wow effects” here… we want to simulate a real-world example

First look

Let us open the report for the first time…

1 2 3

45

Where is my problem?

o A simple report like this, is already too complex

o Three measures:

• Amount USD, Amount EUR, Open Orders

o Different ways of slicing and combining values

o Trial and error is not the way to go

o Do you really want to google “what’s wrong with my

report”?

DAX Studio

o The ultimate tool for working with DAX queries

o Completely free

o Works with Power BI, Power Pivot, SSAS Tabular, Azure

Analysis Services

o It provides tons of information, but you need to be able

to read it

o Download and install from www.daxstudio.org

Fighting with the cache

o There are multiple cache levels

• they are your enemies as of now

o Power BI cache

• Useful when authoring reports

• Avoids executing the query at all if not needed

o DAX cache

• Caches results of internal VertiPaq queries (more on this later)

• Can be cleared from withing DAX Studio

o Avoid the cache to measure performance

Create an empty page in Power BI

o An empty page lets you start Power BI Desktop without

computing any report

o Open Power BI on the empty page

o Open DAX Studio and connect to Power BI

o Start tracing all queries

o Collect the results

o Stop the tracing

1

2 34

5

Currency Conversion

Focus on DAX to search for a better way to write currency conversion

Following best practices

o Best practices are always helpful

• there are not so many in DAX

• it is easier to follow them

o Use variables as much as you can to fix values

o Avoid computing the same value multiple times

o Make it simpler, then simpler, then… simpler

The two engines in DAX

The two engines in DAX

Differences between the engines

Formula Engine

• Computes any DAX function

• Very rich in terms of expressivity

• Single threaded

• Slow side of DAX

Storage Engine

• Computes simple expressions

• Uses model relationships

• Multi threaded

• Fast side of DAX

Performance

Open Orders

Next step is optimizing the open orders measure

October, 2017

Open Orders

Order 1

Order 2

Order 3

Order 4Order 5

Open Orders = 3

October, 2017

Changing the data model

Order 1

Order 2

Order 3

Order 4Order 5

Conclusionso Download and install DAX Studio

• get ready to spend time learning

o Measure, test, change, loop

o DAX Studio is your best friend here

o Optimizing is a complex process

• It requires a deep understanding of the internals

• Formula engine, storage engine, data caches, columnar

databases

o At www.sqlbi.com you will find plenty of resources on DAX

Thank you!

Check our articles, whitepapers and courses on

www.sqlbi.com