Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
mlozano
Helper II
Helper II

Optimize DAX

helHello, I have the following problem.

 

I have the following formula, which is giving me the correct result, the drawback is that the performance is very slow. I would like to know if I have any way to optimize the performance of my measure. It is a very long formula so I could not add it to the publication, I leave a link with notepad that contains my measurement.

 

Measure 

 

 

 

2 ACCEPTED SOLUTIONS
johnt75
Super User
Super User

A quick win would be to use variables to store the results of calculations which are currently being done multiple times. e.g.

CALCULATE (
                        SUM ( Worksheet[LE Volume] ),
                        ALLSELECTED ( Worksheet ),
                        VALUES ( Worksheet[Month] ),
                        VALUES ( Worksheet[Category] )
                    )

is done multiple times and must be calculated every time. Store the result in a variable so you only have to do the calculation once.

View solution in original post

daXtreme
Solution Sage
Solution Sage

Hi @mlozano 

 

1. Must the measure be that long?

2. Have you removed all duplication from it?

3. Instead of IF's, have you tried to use SWITCHes?

4. Have you tried to optimize each small piece of the measure so that it's fast when applicable?

5. The problem is that if you have many variables calculated outside of IF/SWITCH, then DAX very often, or even 95%+ of the time, will try to calculate EVERYTHING regardless of whether a variable will or will not be needed for the final calculation. Therefore it's so important to place the calculation of variables in the correct places, that is under IF/SWITCH.

View solution in original post

2 REPLIES 2
daXtreme
Solution Sage
Solution Sage

Hi @mlozano 

 

1. Must the measure be that long?

2. Have you removed all duplication from it?

3. Instead of IF's, have you tried to use SWITCHes?

4. Have you tried to optimize each small piece of the measure so that it's fast when applicable?

5. The problem is that if you have many variables calculated outside of IF/SWITCH, then DAX very often, or even 95%+ of the time, will try to calculate EVERYTHING regardless of whether a variable will or will not be needed for the final calculation. Therefore it's so important to place the calculation of variables in the correct places, that is under IF/SWITCH.

johnt75
Super User
Super User

A quick win would be to use variables to store the results of calculations which are currently being done multiple times. e.g.

CALCULATE (
                        SUM ( Worksheet[LE Volume] ),
                        ALLSELECTED ( Worksheet ),
                        VALUES ( Worksheet[Month] ),
                        VALUES ( Worksheet[Category] )
                    )

is done multiple times and must be calculated every time. Store the result in a variable so you only have to do the calculation once.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.

Top Solution Authors