Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Best way to handle nested ifs

Hello.

We have an application with over 100 millions of records with four main subjects and the report sheet has several tables with delta (up/down arrows)  indicators and light indicators (red, green or yellow according to the conditions).  We are facing performance issues, it takes over 30 seconds to load all the six tables with 24 expressions, so it needs to be faster. I was reading about the performance tips in the community, and many mention the nested ifs So, I want to check the best way to evaluate this type of indicators. Right now, this is the structure of this indicators:

Light Indicator:

if( $(variable1)/$(variable2) > 1, [green color image],

     if($(variable1)/$(variable2) < 1 and $(variable1)/$(variable2) > $(vLimit), [yellow color image],[red color image]

     )

)

Delta Indicator:

if( $(variable1)/$(variable2) > 1, [up arrow], [down arrow])

and in the text color:

if( $(variable1)/$(variable2) > 1, [green color],

     if($(variable1)/$(variable2) < 1 and $(variable1)/$(variable2) > $(vLimit), [yellow color],[red color]

     )

)

Is there a better way?

Thanks in advance for any help.

1 Reply
sebastiandperei
Specialist
Specialist

Hi. In first place, you should take a look in your data model. QVW Size? No of tables? Table structure? do you have synthetic keys?

In second place, some times you can put these indicators in a table, or just in text boxes, so for know how is the best way, you should send a reduced copy of the qvw.

Finally, you are making calculations and comparations in every    if  a/b > 1, where you could do just comparations with  if  a>b. Also, always thin about doning less calculus as possible. Look for another version for your first exp:

Light:

if (  $(var1) > $(var2), [green],

  if ( $var1) > $(var2) * $(Limit), [yellow], [red]))

What do you have in the variables?

Another thing to do is don't use images. So, if you want, send a reduced sample to know the best solution.