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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
WSeirafi
Helper I
Helper I

IF statement performance

Hello,

 

I'm witnessing a performance issue for a quite simple measure used in a big table.
If I use this measure, the result is instant

Measure =
VAR CurrentVal = SELECTEDVALUE ( Table[Column] )
RETURN
    CurrentVal
 
However if I use this measure
Measure =
IF (
    ISBLANK (
        SELECTEDVALUE ( Table[Column] )
    ),
    1,
    0
)
 
The visual goes in error after several minutes loading. What is that due to and is there a way around this ?

Regards
7 REPLIES 7
shafiz_p
Super User
Super User

Hi @WSeirafi  With "if" statements, you need to go through each item one by one. When you have a huge table , using "if" statements can be slow. It’s like checking each item individually. The default query timeout is 225 seconds. Please check its performance. Try with switch function, because it faster than "if".

I answered below, unluckily it was not effective

Greg_Deckler
Community Champion
Community Champion

@WSeirafi ISBLANK is notorious for bad performance. Try this:

 

Measure =
IF (
    SELECTEDVALUE ( Table[Column] ) = BLANK(),
    1,
    0
)

 

or

 

Measure =
IF (
    SELECTEDVALUE ( Table[Column] ) <> BLANK(),
    0,
    1
)

or

Measure =
SWITCH( SELECTEDVALUE ( Table[Column] ),
    BLANK(), 1,
    0
)

 



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

I tried with both suggestions you gave

Measure =
VAR CurrentVal = SELECTEDVALUE ( Table[Column] )
RETURN
    SWITCH(CurrentVal,
        BLANK(),1,
        0
    )
Didn't change anything. There is no other way to do this ?
I would have added a calculated column, but this is supposed to be reacting to a slicer

@WSeirafi It's hard to say with the information provided. Would need additional context of the problem you are actually trying to solve. Is this something that could be done using the Filter pane?



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hello,

 

I ended up merging all my data into one big table for this purpose, but my issue now is that when I use a Switch / if measure in my table, the slicer do not have any effect on it.

I guess it's the fact that the IF measure returns a value for every rown but how can I prevent this from happening ?

Thanks for your help

Might be a solution

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.