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: 
Not applicable

Rolling 6 months

Hi,

I am preparing inventory turnover report and I would like to add there a calculation that shows moving 6 month average

I know this is simple question for most of you, but I am still quite rookie with Qlikview, so I would highly appreciate your help

To clarify my issue, I have attached example below. In my data, there is year, period, inventory and monthly usage information. What I would like to come up with is these two six months rolling average columns (Inventory (six months avg) 1037 is the average of inventories in periods 2011/1-2011/6) 

YearPeriodInventoryUsageInventory (rolling six month
  avg)
Usage (rolling six month avg)
201111000-100
201121100-90
201131050-110
201141000-105
20115990-110
201161080-701037-98
201171050-1001045-98
201181010-901030-98
20119910-1501007-104
201110950-150998-112
201111960-100993-110
2011121000-90980-113
201211000-100972-113
201221100-90987-113
201231050-1101010-107
201241000-1051018-99
20125990-1101023-101
201261080-701037-98
201271050-1001045-98
201281010-901030-98
20129910-1501007-104
201210950-150998-112
201211960-100993-110
2012121000-90980-113

I think this would be easiest to do in expression instead of script?

Thanks

Regards

Janne

7 Replies
thanstad
Creator
Creator

Try this,

=rangeavg(above(avg(field),0,6))  you can use Above for calculating on previous observations. You need of course in this example to group your data by month. 0 is the starting line and 6 is the number of observation above this. If you put this into at linechart with a spline option it will be nice. Check out the help on range - there are a lot of possibilities on this functions.

Good luck!

Tormod Hanstad

er_mohit
Master II
Master II

Try this

rangeavg(above(avg(aggr(Inventory,Period,Year)),0,6))

Gysbert_Wassenaar

This document may help you find which solution works best for you: Calculating rolling n-period totals, averages or other aggregations


talk is cheap, supply exceeds demand
Not applicable
Author

Thanks for your hints! But I am struggling to utilize them. I have now the table below. This view is for one material and I would like to see in the last column the average of the current and previous period. For some strange reason the rangeavg formula there doesn't do the job. Is it somehow wrong or do I have some kind of problem with my data?

klikki.JPG.jpg

Not applicable
Author

Try This

avg({<Date={'>=$(Vrolling6)<=$(vMaxDate)'}>}Monthendvalue)

Vrolling6=Date(MonthStart(vMaxDate,-5),'DD/MM/YYYY')

Vmaxdate=Date(max(Date),'DD/MM/YYYY')

thanstad
Creator
Creator

Hello Janne, I tried based on your data and it seems to work here by my. range_input.PNGrange_capture.PNG

Not applicable
Author

Ok, I was thinking also that this should work, but it doesn't for me. Would you mind sending your qvw file that I could see in where I am doing this wrong?

Thanks!

Janne