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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

get acumulative values in a expression

Hello there,

Anybody know how to get acumulative values in a expression but not using expression's acumulative options but from the expression, i.e: getting acumulative sales by periods. It would be something like "=Sum(SALES)" with "PERIOD" as dimension but addin or changing something else in order to get acumulative sales by period.

Thanks again for your help,

1 Reply
johnw
Champion III
Champion III

If I understand your question, something like this:

// create new table with all distinct periods
// this approach is faster than using LOAD DISTINCT
AsOf:
LOAD fieldvalue('Period',iterno()) as Period
AUTOGENERATE 1
WHILE len(fieldvalue('Period',iterno()))
;
// join every Period to every AsOfPeriod
LEFT JOIN (AsOf)
LOAD Period as AsOfPeriod
RESIDENT AsOf
;
// remove future periods
INNER JOIN (AsOf)
LOAD *
RESIDENT AsOf
WHERE Period <= AsOfPeriod
;
// each AsOfPeriod is now linked to the current and previous periods

Then use AsOfPeriod as the dimension instead of Period, and a plain old sum(Sales) as your expression. All the magic to do the accumulation happens as a result of the data model.