Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
semgem12
Contributor III
Contributor III

Rolling values with weeks and periods

Hello, hope someone can help with this please.


I have a table of values which are stored by financial period (not month) and week. Each period has a number of weeks, e.g. period 1 always has 4 weeks, but period 2 always has 5 weeks. The weeks just roll forward, they don’t restart at 1 each time a period starts. There are 12 periods and 52 weeks per year.

E.g.

Load * inline [

Period,Week,Value

1, 1, 25.00

1, 2, 30.00

1, 3, 27.00

1, 4, 23.00

2, 5, 28.00

2, 6, 29.00

2, 7, 22.00

2, 8, 32.00

2, 9, 21.00

3, 10, 19.00

];

I have to show this table as a Qlik Sense table in the same format as above but I need another column that shows the value as a rolling value that restarts at each period, i.e.

PeriodWeekValueRolling ValueNotes

1

125.0025.00week 1
1230.0055.00week 1+2
1327.0082.00week 1+2+3
1423.00105.00week 1+2+3+4
2528.0028.00new period, so just week 5
2629.0057.00week 5+6
2722.0079.00week 5+6+7
2832.00111.00week 5+6+7+8
2921.00132.00week 5+6+7+8+9
31019.0019.00new period, so just week 10 etc.

I think I need to use rangesum(above(Value)) in some way but can’t work out how.

Thanks for any help.

5 Replies
pradosh_thakur
Master II
Master II

load *, if(peek(Period)=Period ,Value +peek(Value),Value) as Rolling_value,

;

Load * inline [

Period,Week,Value

1, 1, 25.00

1, 2, 30.00

1, 3, 27.00

1, 4, 23.00

2, 5, 28.00

2, 6, 29.00

2, 7, 22.00

2, 8, 32.00

2, 9, 21.00

3, 10, 19.00

];

Learning never stops.
ogautier62
Specialist II
Specialist II

Hi,

in the graph

[rolling value] = if(rowno()=1,value,above([rolling value]) + value)

regards

semgem12
Contributor III
Contributor III
Author

Thank you, unfortunately this does not work. It seems to add successive pairs of values,

i.e.

  

PeriodWeekSum(Value)sum(Rolling_value)
112525week 1
123055week 1+2
132757week 2+3
142350week 3+4
252828etc.
devyanshu_gupta
Partner - Contributor III
Partner - Contributor III

Hi,

Try this

Load *,

if(Period=peek(Period),peek(Rolling_Value)+Value,Value) as Rolling_Value

Resident Table

Order By Period,Week;


Regards,

Devyanshu

ogautier62
Specialist II
Specialist II

Hi,

just rolling_value , not sum(rolling_value)  !