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
Ronald123
Resolver III
Resolver III

Performance issue switch measure

 

Hello,

 

I have a measure in my report for counting the sum of the orderbook.

This measures must check two criteria. One for the days to count en the other te ratecode.

 

Below a part of the selection of this measure. 

 

Is it possible to write this measures better for a lower CPU?

 

Thanks,

 

Ronald

 

OrderbookDays= SUMX(ContItems;

                SWITCH(TRUE();

        [CountDays]=1 && ContItems[RATECODE]="STD";ContItems[RATE#1];

        [CountDays]=1 && ContItems[RATECODE]="FERR";ContItems[RATE#1];

        [CountDays]=1 && ContItems[RATECODE]="STD3";ContItems[RATE#1];

        [CountDays]=2 && ContItems[RATECODE]="STD";ContItems[RATE#2];

        [CountDays]=2 && ContItems[RATECODE]="FERR";ContItems[RATE#2];

        [CountDays]=2 && ContItems[RATECODE]="STD3";ContItems[RATE#2];

        [CountDays]=3 && ContItems[RATECODE]="STD";ContItems[RATE#3];

        [CountDays]=3 && ContItems[RATECODE]="FERR";ContItems[RATE#3];

        [CountDays]=3 && ContItems[RATECODE]="STD3";ContItems[RATE#3];

        [CountDays]=4 && ContItems[RATECODE]="STD";ContItems[RATE#4];

        [CountDays]=4 && ContItems[RATECODE]="STD3";ContItems[RATE#4])

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @Ronald123,

 

I don't suggest you to use complex calculate formula as expression with sumx or other functions who contains loop features.(Obviously, it will affect performance)


For your scenario, you can try to use below measure if it work on your side with cost less system resource.

OrderbookDays =
SUMX (
    ContItems;
    IF (
        ContItems[RATECODE] IN { "STD"; "STD3"; "FERR" };
        SWITCH (
            [CountDays];
            1; ContItems[RATE#1];
            2; ContItems[RATE#2];
            3; ContItems[RATE#3];
4; ContItems[RATE#4] ) ) )

Optimizing DAX expressions involving multiple measures

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

1 REPLY 1
v-shex-msft
Community Support
Community Support

Hi @Ronald123,

 

I don't suggest you to use complex calculate formula as expression with sumx or other functions who contains loop features.(Obviously, it will affect performance)


For your scenario, you can try to use below measure if it work on your side with cost less system resource.

OrderbookDays =
SUMX (
    ContItems;
    IF (
        ContItems[RATECODE] IN { "STD"; "STD3"; "FERR" };
        SWITCH (
            [CountDays];
            1; ContItems[RATE#1];
            2; ContItems[RATE#2];
            3; ContItems[RATE#3];
4; ContItems[RATE#4] ) ) )

Optimizing DAX expressions involving multiple measures

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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.