Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
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
;
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;
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