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
arnold61
Regular Visitor

Do not evaluate else part of IF function if the condition is met

Hi Community,

I am facing some issues with the performance of the DAX code and it seems like I have found a bottleneck for it. 

Just for a background, in my reports, I show values for companies and for benchmarks. The benchmark logic is quite complex and has to compute more data than simply selected companies, that is why the default state of a report is only selected companies so that it will open up fast and then the user can select a benchmark additionally. 

All companies have positive number IDs and all benchmarks have negative number IDs. That's how we distinguish then. 

So, I have an IF function inside my DAX like this: 

IF(ID>0, [simple logic for companies], [complex logic for benchmarks]). 

The formula itself works perfectly fine, however, even when we only look at the selected companies the time for computation is still the same as it would've been for benchmarks. When I remove the else statement the loading time is less than 5 seconds, but when I add it back, even though the condition ID>0 is true and the else statement should not be evaluated the loading time grows to 10-15 seconds. 

I have read it might be because of the eager evaluation taking place, so we need to somehow trigger the strict evaluation so that only the first part of DAX is evaluated, but I could not find a way to do it. 

I would appreciate any ideas regarding this.

6 REPLIES 6
SpartaBI
Community Champion
Community Champion

@arnold61 did you try IF.EAGER instead of IF?

This doesn't work 

@arnold61 maybe you have totals in your visual?, that could cause this, and maybe you don't need them

@SpartaBI thanks for the idea,but no,we have no totals, but do totals influence the behaviour of the if function?

if somehow fot the total the else if kicks in. Hard to say anything with the info supplied 🙂

For more information the DAX is used in a calculation group, because we need to apply it to all measures used throughout the report.The example of the usage below:

arnold61_0-1655903703049.png

 

When a customer selects companies the simple logic is applied to the measures, and when Benchmarks the complex one. The default state of the report is only companies. An important note is that Companies and Benchmarks should be in the same visual and not in the separate ones, that is the requirement.

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.