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

Performance Issue with IF Conditions

Hi Everyone,

I am hitting performance issue if i use the nested IF statements. Could some one please explain how IF ELSE is exactly executing in QV. Let me know if there are any better functions to use to improve performance.

When i use the below nested if ,the performance is very very slow.

If( option=product1,

     expression1,

          if( getselectedcount(product)=0,

          expression2,

           expression3

               )

     )

To resolve performance issue i divided this expressions into 2 expressions in 2 charts.Based on the selections i am hiding one of the chart.This way performance is much much better. But i used the same expressions

Chart1: Display chart1 only If( option=product1) or if( getselectedcount(product)=0 and expression is

If( option=product1,

     expression1,

     expression2)

Chart2: Display chart2 only if( getselectedcount(product)>0 and expression is

     expression3

4 Replies
disqr_rm
Partner - Specialist III
Partner - Specialist III

In your case, I would rather have 3 expressions on one chart and hide expressions based on your conditions.

So first expression is only visible if option=product1. This was you will see expression field based on your conditions and performance should be good.

Other ways are to look into script and make adjustments you you are able to use SET ANALYSISinstead of IF conditions. Expressions with IF conditions will always be slow. Avoid as much as you can.

Hope this helps.

Rakesh

ToniKautto
Employee
Employee

Would say that your performance is a result of your data model and the expressions you run the data set, so by default your setup with two if statements would not cause problem but rather the expressions you use. For a better evaluation if your issue and enable providing suggestions on improvement, please attach a sample QVW where your data model and expressions can be evaluated.

Assuming the QVW is quite large you could start by attaching a file emptied on data;

File > Reduce Data > Remove All Values

Not applicable
Author

Thank you rakesh n toni for the response.

Rakesh, Could you give some sample example, how to hide expressions based on condition? I think the "IF" is checking condition then based on condition corresponding expressin is considered.

Toni, Yes my data model is very big. My QVW size is 800MB. But when i use one chart with nested IF statetements, the performance is very very slow. But when i spit the chart into 2 charts performance is much better. Both are using same data model and same volume of data. My question is why performance is slow when we use the nested IF statemetns against splitting the charts.Below is the exact expression i used.

if(v_Options='Product' OR v_Options='Product Strength',

      (Sum($(v_Rx))

   /

   Sum (TOTAL <MonthYear>$(v_Rx)))

   ,

    IF(GetSelectedCount(Product2)=0,      

  (Sum({<Product={'XXXXX'}>}$(v_Rx))

        /

       Sum (TOTAL <MonthYear,$(v_SalesPerformance_Dimension)>$(v_Rx))

       ),

      

       (Sum({<Product={'$(=Product2)'}>}$(v_Rx))

    /

       Sum (TOTAL <MonthYear,$(v_SalesPerformance_Dimension)>$(v_Rx))

       )

      )

   

   

   )

ToniKautto
Employee
Employee

Thanks for the additional details. I am still a bit unclear on the two setups that you comapre, could you please attach two sample files where you have removed all data to make the files small. Please leave all the layoutr that you have so the application setup can be properly evaluated.

Note, you can attach files by editing an existing entry in the community thread.