Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Please help! , dont know how to use aggr() to calculate sum()

Hi guys , please i need your help.

I have an app with  this Chart :

A "timeline" that shows , from the different events that one worker produces on the system ,  the time between them .

     1. Dimension : Datetime ,  i make this transformation to show in Human readable form : =date(dt)&'-'&time(dt)  (setting order by expression dt)

     2. Measure : The time interval between events :=dt - Above(dt)

This Value is calculated in the chart depending on the selections done so , is recalculated every time i take other user and day .

if y put on the measure this formula dt-above it works , if i create a master measure TimeInterval = dt-above(dt) it doesnt .

How can i calculate the sum of all the intervals with aggr() ,

aggr(sum(TimeInterval) , dt ) doesnt work .

aggr( sum (dt - above(dt) ) , dt ) either..

Please can you help me?

4 Replies
swuehl
MVP
MVP

Maybe something like



Sum( Aggr(

          dt - above(dt)  ,

         ( dt, (NUMERIC, ASCENDING))

) )

Not applicable
Author

HI Swuehl, thanks for your help, this field is ordered in the script:

[EVENTS]:

NoConcatenate

LOAD * Resident TEMP

ORDER BY id_user , dt ;

But id does not work ...

swuehl
MVP
MVP

This will not determine the LOAD order of your dt field, since it has already loaded into the data model in the TEMP table.

If you are not using QV 12 or QS (where you can use the structured parameter), you would need to create a LOAD script where the LOAD order is correct. With your above script snippet, I assume what you can do is something like

[EVENTS]:

NoConcatenate

LOAD * Resident TEMP

ORDER BY id_user , dt ;

STORE EVENTS into Events.qvd (qvd);

DROP TABLE TEMP;

DROP TABLE EVENTS;

LOAD * EVENTS FROM Events.qvd (qvd)

swuehl
MVP
MVP

In addition, please clarify the role of id_user. Maybe your ORDER BY should just be

[EVENTS]:

NoConcatenate

LOAD * Resident TEMP

ORDER BY dt ;