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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ChrisCarrVictra
New Member

Dax CPU Optimization for Capacity

Hello,

 

I inherited a report that is performing extremely poorly from a CPU usage and constantly making our capacity auto scale daily. I am wondering if there is a defined best practice when trying to use the summarize function using a measure as one of the columns to summarize. Here is an example of the code that gives the correct outputs but is incredibly inefficient in terms of CPU and causing a lot of capacity issues as this is a primary measure that is used by a lot of people and the data it runs on top of is ~125M records. The [Overall Points] measure has ~40 measures that feed into it (was not my doing). This measure also has a bunch of averages and other rank measures that reference this measure so that is why the "relevance" is lower than it really is.

 

VAR Summary =
    SUMMARIZE (
        FILTER (
            ALL ( Stores ),
            'Stores'[Area] IN { "East", "West" } && 'Stores'[StoreName] <> "VA-Bluefield"
        ),
        Stores[StoreName],
        "Overall Points", [Overall Points]
    )
RETURN
    RANKX (
        Summary,
        [Overall Points],, DESC
    )

Dax Optimizer says the following around the measure. 

ChrisCarrVictra_0-1713384469312.png

 

 

ChrisCarrVictra_1-1713384488544.png

 

 

 

If there was a way to get a calculated table to update based on the date range a user enters that would be my ideal solution.

2 ACCEPTED SOLUTIONS
Greg_Deckler
Super User
Super User

@ChrisCarrVictra This may give you better performance but it sounds like you need to optimize your Overall Points measure:

VAR Summary =
    SUMMARIZE (
        CALCULATETABLE( 'Stores', 'Stores'[Area] IN { "East", "West" }, 'Stores'[StoreName] <> "VA-Bluefield" ),
        Stores[StoreName],
        "Overall Points", [Overall Points]
    )
RETURN
    RANKX (
        Summary,
        [Overall Points],, DESC
    )

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

v-jianpeng-msft
Community Support
Community Support

Your point of view is great @Greg_Deckler . I have the following additions:

Hi, @ChrisCarrVictra 

If you need to optimize your complex DAX expressions, you can refer to the following article:

Optimizing DAX expressions involving multiple measures - SQLBI

vjianpengmsft_0-1713948310442.png

 

In the following articles, there are tutorials for optimizing different DAX functions:

Optimization - SQLBI

vjianpengmsft_1-1713948469754.png

 

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-jianpeng-msft
Community Support
Community Support

Your point of view is great @Greg_Deckler . I have the following additions:

Hi, @ChrisCarrVictra 

If you need to optimize your complex DAX expressions, you can refer to the following article:

Optimizing DAX expressions involving multiple measures - SQLBI

vjianpengmsft_0-1713948310442.png

 

In the following articles, there are tutorials for optimizing different DAX functions:

Optimization - SQLBI

vjianpengmsft_1-1713948469754.png

 

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Greg_Deckler
Super User
Super User

@ChrisCarrVictra This may give you better performance but it sounds like you need to optimize your Overall Points measure:

VAR Summary =
    SUMMARIZE (
        CALCULATETABLE( 'Stores', 'Stores'[Area] IN { "East", "West" }, 'Stores'[StoreName] <> "VA-Bluefield" ),
        Stores[StoreName],
        "Overall Points", [Overall Points]
    )
RETURN
    RANKX (
        Summary,
        [Overall Points],, DESC
    )

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler 
😲 is this you who just suggested CALCULATETABLE or am I dreaming? 😅 Looks like you started to like the function 😂

@tamerj1 Lol! I never had an issue with CALCULATETABLE. In fact, in my opinion, the No CALCULATE approach (VARs, Table VAR, Table Aggregator) without CALCULATE or CALCULATETABLE can solve probably 90% or more of all DAX problems. You add CALCULATETABLE and you are at 99.99% of all DAX problems solved. And, it's the exact same pattern it's just that you use CALCULATETABLE when creating your Table VAR. Still no CALCULATE though! 🙂


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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