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

Optimizing a Calculation [sum(aggr(if(...)))]

Good morning,

I need to calculate the disting companies that meet some requerements (KEY_EMPRESA). This formula works perfectly, with the drawback that it takes more that 3 minutes to run, wich is too much time. We have upgraded the server (more RAM, CPU, ..), but the time did not changed.


[WORKS] - sum(aggr(if(Orden_ACT=max(total<KEY_EMPRESA> Orden_ACT) ,1,0),KEY_EMPRESA, Orden_ACT))


I am trying to rewrite this formula in order to make it more efficient... with something like: [where CONTADOR is allways 1)


[EXAMPLE - DOES NOT WORK] - aggr(sum({<Orden_ACT={max(total<KEY_EMPRESA> Orden_ACT)} >} CONTADOR), KEY_EMPRESA, Orden_ACT)

I am blocked at this point. Do you have any idea??

Thanks in advance,

Javier

6 Replies
tresesco
MVP
MVP

What are your dimensions in the chart? Or, is it somewhere in textbox?

Anonymous
Not applicable
Author

We have two dimension, to build the following table data:

ACTIVITY DESCRIPTIONTYPEHMETotal
AGENTES INMOBILIARIOS [2197]--44
AGENTES Y REPRESENTANTES COMERCIALES [3478]5-712
AGRICULTURA [2151]171276294
AGRICULTURA CONSULTORIA [4952]--11
Total 22 1 288 311

Regards,

Javier

tresesco
MVP
MVP

Is it :

KEY_EMPRESA - Activity Description

Orden_ACT - Type ?

If so, you can possibly avoid using Aggr() and that would significantly improve performance.

Anonymous
Not applicable
Author

Unfortunately NOT.

  KEY_EMPRESA = is the company code. Is it used to count the distinct numer of companies that meet the requirements

  ORDEN_ACT = is a number that it is used to decide where to count the company. The company must be counted where the ORDEN_ACT is the maximum for the given KEY_EMPRESA.

  ACTIVITY_DESCRIPTION = is an dimension that must be in ROWS.

  TYPE = Another dimension that must be in COLUMNS

Hope it is more clear now,

Javi

tresesco
MVP
MVP

Try removing 'total<KEY_EMPRESA>' part from the expression.

Anonymous
Not applicable
Author

I did try, but I am not getting the same values (which we verified are ok).

Find a sample QV attached.

Best

Javier