Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
ivan_will
Contributor II

Weighted average for every quarter using the last 4 quarters

Hi,

please find attached an xls file with an example in it:

the idea is as follows:

for every quarter, for every ID I want to have weighted average Number - so for 31/03/2013 it should be the following:

(Number*daysInQuarter  (31/03/2013) + 

Number*daysInQuarter  (31/12/2012) + 

Number*daysInQuarter  (30/09/2012) + 

Number*daysInQuarter  (30/06/2012)) /  (90+92+92+91) = 75

for the previous it should be :

(Number*daysInQuarter  (31/12/2012) + 

Number*daysInQuarter  (30/09/2012) + 

Number*daysInQuarter  (30/06/2012) + 

Number*daysInQuarter  (31/03/2012)) /  (92+92+91+91) = 65

And I want to have this in the script - the same as the below table. So if you have something similar it would be a help. Thanks!

IDDateNumber daysInQuarter
we31/03/201110 89#VALUE!
we30/06/201120 91#VALUE!
we30/09/201130 92#VALUE!
we31/12/201140 9225.13736264
we31/03/201250 9135
we30/06/201260 9144.94535519
we30/09/201270 9255
we31/12/201280 9265.05464481
we31/03/201390 9074.95890411

Thanks in advance!

1 Solution

Accepted Solutions

Re: Weighted average for every quarter using the last 4 quarters

See attached example.


talk is cheap, supply exceeds demand
3 Replies

Re: Weighted average for every quarter using the last 4 quarters

See attached example.


talk is cheap, supply exceeds demand
ivan_will
Contributor II

Re: Weighted average for every quarter using the last 4 quarters

yes, it works fine, but now another question:

if we have another date with change - let's say 21/03/2013 - number= 77

how to calculate the weighted average in qv script for the quarter/s??

regadrs

ivan_will
Contributor II

Re: Weighted average for every quarter using the last 4 quarters

??

Community Browser