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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Analitika
Post Prodigy
Post Prodigy

Very slow measure

Why this measuare is very very slow?

 

 

 

Mesuare =
VAR sum1 = [mesuare1] - [measure2]
VAR sum2 = [mesuare3] - [measure4]
VAR discount =
    SWITCH (
        TRUE (),
        "disc1" IN DISTINCT ( Table2[name1] ), sum1, //Here i need toggle sum1 form negative to positive only for "disc1" values
        "disc2" IN DISTINCT ( Table2[name1] ), sum1, //Here i need toggle sum1 form negative to positive only for "disc2" values
        -sum1  //Here i need toggle sum1 form negative to positive for other
    )
RETURN
    SWITCH (
        TRUE (),
        "Name1" IN DISTINCT ( Table1[name] ), discount, // Show this sum in Name1 having values
        "Name2" IN DISTINCT ( Table1[name] ), sum2 // Show this sum in Name2 having values
    )

 

 

 

How to speedup it?

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

Hi @Analitika ,

 

There are 2 "switch" funtion in the sam measure that may take much CPU in calculation,pls try to replace the first switch funtion with "if",you may try to modify as below:

VAR discount =
    IF (
       "disc1" IN DISTINCT ( Table2[name1] )|| "disc2" IN DISTINCT ( Table2[name1] ), sum1, -sum1 

)

 
Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

View solution in original post

4 REPLIES 4
v-kelly-msft
Community Support
Community Support

Hi @Analitika ,

 

There are 2 "switch" funtion in the sam measure that may take much CPU in calculation,pls try to replace the first switch funtion with "if",you may try to modify as below:

VAR discount =
    IF (
       "disc1" IN DISTINCT ( Table2[name1] )|| "disc2" IN DISTINCT ( Table2[name1] ), sum1, -sum1 

)

 
Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
amitchandak
Super User
Super User

@Analitika , please let us know what are trying to achieve here

I need toggle wrong negatives sum if this is discounts

Pragati11
Super User
Super User

Hi @Analitika ,

 

First thing SWITCH function returns a scalar value, but in your DAX you are trying to return a table against "VAR discount".

 

What you can do is convert this "VAR discount" variable to a measure, then use it in your SWITCH statement which is in RETURN part of your dax expression.

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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