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

Announcements
Learn how to migrate to Qlik Cloud Analytics™: On-Demand Briefing!
cancel
Showing results for 
Search instead for 
Did you mean: 
susopark
Contributor II
Contributor II

Adding Up Values from Different Loads

Greetings to Qlik Community,

I'm a newbie with Qlik Sense, therefore I am not familiar with scripting at the moment.

I was trying to add monthly values from different LOADS, however it returns me results sets that I wasn't looking for. 

 

I'll explain it with an example:

Table1

LOAD

YearMonth   Value

201901           2

201902           5

201903          10

 

LOAD

YearMonth   Value

201902          6

201903          14

201904          2

 

The result set I want is the monthly accumulation that adds up for the next months, therefore:

YearMonth   Value

201901          2

201902          8 (2+6 and not 2+5, as the 6 is the newest value for 201902)

201903          22 (8 + 14)

201904          24 (22+2)

 

What I don't want is the adding up for each month, but the accumulations of it that tops up for with the value of the following month.

 

If further explanations are needed don't hesitate to ask.

 

Thank you in advance.

 

Labels (6)
3 Replies
eddie_wagt
Partner - Creator III
Partner - Creator III

For this solution you need a reference date if new data is being loaded. For example daily. 

 

Table1:

LOAD * INLINE [YearMonth  , Value, Date

201901       ,    2, 01-01-2022

201902      ,     5, 01-01-2022

201903       ,   10, 01-01-2022
] (delimiter is ',');

LOAD * INLINE [YearMonth ,  Value, Date

201902       ,   6, 02-01-2022

201903    ,      14, 02-01-2022

201904    ,      2, 02-01-2022
] (delimiter is ',');

Table2:
LOAD 	YearMonth
,		RangeSum(peek('Cumulative') , LastValue) AS Cumulative
;
LOAD YearMonth
,	 FirstSortedValue(Value,-Date) as LastValue
Resident Table1
Group By YearMonth
;

//optional drop
Drop table Table1
;

 

eddie_wagt
Partner - Creator III
Partner - Creator III

Like this?

 

Data:
LOAD * Inline [
Date,Value
201810,22
201811,22
201812,10
201901,14
201902,18
201903,18
201904,21
];

Final:
LOAD Date
,	 Value
, 	 if(Previous(Year)=Year,RangeSum(Value,Peek(Valuee)),Value) as Valuee
;
NoConcatenate
LOAD
left(Date,4) as Year,
Date,
Value
Resident Data
Order by Date;

Drop Table Data;
susopark
Contributor II
Contributor II
Author

Thank you so much @eddie_wagt !!! It Worked. 

I deleted the last comment as it was a different topic.

I'll provide you the new link of the post, where you can post your answer and I'll validate it as a solution

 

https://community.qlik.com/t5/New-to-Qlik-Sense/Cumulative-till-month-12-of-a-year-and-the-reset-the...