Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
antosraf
Contributor III
Contributor III

YTD to Month in loading script

HI All

Can you give some ideas how to split YTD data to month

I have YTD data so feb is sum of Jan and Feb and so on, I need some loop to recalculate this and have data per month.

orginal data

load * inline
[
period,Product,Value
201801,A,100
201801,B,110
201802,A,220
201802,C,100
201803,A,200
201803,B,200
201803,C,120
]

 

I need

period Product Value 
201801A100
201801B110
201802A120
201802C100
201803A-20
201803B90
201803C20

 

BR

Rafal

 

 

1 Solution

Accepted Solutions
Vegar
MVP
MVP

image.png

I got this tablebox from the script below.

RawData:
load * inline
[
period,Product,Value
201801,A,100
201801,B,110
201802,A,220
201802,C,100
201803,A,200
201803,B,200
201803,C,120
] 
;
FinalData:
LOAD 
period,
Product,
Value, if(peek('Product')= Product, Value - Peek('Value'), Value ) as MonthlyValue Resident RawData ORDER BY Product, period ; DROP Table RawData;

View solution in original post

2 Replies
Vegar
MVP
MVP

image.png

I got this tablebox from the script below.

RawData:
load * inline
[
period,Product,Value
201801,A,100
201801,B,110
201802,A,220
201802,C,100
201803,A,200
201803,B,200
201803,C,120
] 
;
FinalData:
LOAD 
period,
Product,
Value, if(peek('Product')= Product, Value - Peek('Value'), Value ) as MonthlyValue Resident RawData ORDER BY Product, period ; DROP Table RawData;
antosraf
Contributor III
Contributor III
Author

Thanks, this is I was looking for