Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
khaycock
Creator
Creator

Expression causing slow performance

I have this massive expression to work out a standard discount on 4 separate straight tables that is causing me a lot of problems when its being opened in Access Point or if its even opened like normal in QlikView (either doesn't load the table for about 15 minutes or crashes completely). It works fine without the expression so I know that is what is causing the problem but I don't know why its causing these problems.

Is there anything anyone can see in there that might be causing the problem?

=num(

1-(

(if(IsNull([Std Disc%]),1,(1-[Std Disc%]))*(Sum( {<PARTS_TYPE={'Wholegoods'},SHIP_FROM_ORGANIZATION_NAME={'IM','ID'},PD={'1'},DATE_TYPE={'SHIP_DATE'},CM={1},FiscalMonth=,FiscalQuarter=,FiscalYear=>}(UNIT_LIST_PRICE_GBP))))

     /

   Sum( {<PARTS_TYPE={'Wholegoods'},SHIP_FROM_ORGANIZATION_NAME={'IM','ID'},PD={'1'},DATE_TYPE={'SHIP_DATE'},CM={1},FiscalMonth=,FiscalQuarter=,FiscalYear=>}(UNIT_LIST_PRICE_GBP))

    )

,'#.0%')

5 Replies
vishsaggi
Champion III
Champion III

Not sure why, did you try using your textbox and seperate these two expressions and see what value you are getting? Can you share your sample app if possible ?

Anonymous
Not applicable

I can't see anything obvious.  You could try calculating the discount in the load script, it might take a bit longer to load but you should not have any performance issues for the user.

vinieme12
Champion III
Champion III

Does this expression contain fields from different tables?

Are your selections in the same table or related tables?

Do you have reference to an island table?

can you post a snapshot and highlight fields being used or just specify which table has the fields being used in the above expression?

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
marcus_sommer

The slow response of these expression will probably caused from the used fields within them - if they are from different tables which are connected over multiple associations or even loosen tables it will create huge temporary tables on which the aggregations will be performed. So the first step will be to look and to adjust the datamodel.

Beside them your expression looked like a quote but both sum-parts are the same unless your check on [Std Disc%] - maybe you could find a more efficient way to calculate it.

Further instead:

(if(IsNull([Std Disc%]),1,(1-[Std Disc%]))

you could use:

alt(1-[Std Disc%], 1)

and the condition here:

PD={'1'}

should be a numeric one, like:

PD={1}

and not a string-comparison.

- Marcus

evanplancaster1
Contributor II
Contributor II

I know this is a really late response, but it's worth the follow-up if for no other reason than to point out tools available for new developers in 2025 to help optimize their expressions.

To @marcus_sommer 's last comment, this expression has a lot going on that could be trimmed down, but I would submit that it can be trimmed down even further than the suggestion he offered.

Your sums are using the same set expressions and are aggregating on the same field, so they are equivalent. For brevity's sake, let's just refer to that sum as "A" everywhere for the time being. Let's also strip off the num() formatting for the moment so we can focus on the formula itself.

Substituting A in for the sums, your formula becomes:

1-(

(if(IsNull([Std Disc%]),1,(1-[Std Disc%])) * A) 

/ A.

Now, the if-statement tells us we have two options:

Option 1: [Std Disc%] is null. Then that expression simplifies all the way down to:

1 - (1 * A) / A = 1 - A / A = 1 - 1 = 0.

Option 2: [Std Disc%] is NOT null. Then that expression simplifies all the way down to:

1 - ((1-[Std Disc%]) * A) / A = 1 - (1-[Std Disc%]) = 1 - 1 + [Std Disc%] = [Std Disc%].

 

In other words, you could boil this whole formula down to:

alt( [Std Disc%], 0)

 

Now, here's why I'm taking the time to resurrect this nearly decade old thread: Google's Gemini 3.0 Pro AI model is actually the one who optimized this expression and figured all that out for me. Here is a link to that chat so you can see the prompt and its response (which was more than just optimizing the expression--it took the time to ask whether there was another intended purpose for the expression and whether perhaps there was a typo or flaw in the logic): 

https://gemini.google.com/share/3a7e1801d7dc

So for anyone who is having performance issues with an expression, we are now to the point where AI can help you with that!