Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Rolling Average Calculation

Hi,

I have build a QVD with 2 years of data in date lavel and now wanted to build a logic like this
The formula should be Sum(Txn current date)/Average(last 14 days excluding current date) – 1
Example:
10/3/2016 Txn should be compared to average of Txn from (10/2/2016 – 09/19/2016)
10/2/2016 Txn should be compared to average of Txn from (10/1/2016 – 09/18/2016)
10/1/2016 Txn should be compared to average of Txn from (09/30/2016 – 09/17/2016)

Sample Data:

    

Txn10/15/201610/14/201610/13/201610/12/201610/11/201610/10/201610/9/201610/8/201610/7/201610/6/201610/5/201610/4/201610/3/201610/2/201610/1/20169/30/20169/29/20169/28/20169/27/20169/26/20169/25/20169/24/20169/23/20169/22/20169/21/20169/20/20169/19/20169/18/20169/17/20169/16/20169/15/20169/14/20169/13/20169/12/20169/11/20169/10/2016
Partner A100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
Partner B276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
Partner C505152535455565758596061626364656667686970717273747576777879808182838485
Partner D177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212

Required output:

  

Result Set (will always display latest 15 days)
Date ->10/15/201610/14/201610/13/201610/12/201610/11/201610/10/201610/9/201610/8/201610/7/201610/6/201610/5/201610/4/201610/3/201610/2/201610/1/2016
Partner A93.0%93.1%93.2%93.2%93.3%93.3%93.4%93.4%93.5%93.6%93.6%93.7%93.7%93.8%93.8%
Partner B97.4%97.4%97.4%97.4%97.4%97.4%97.4%97.4%97.4%97.4%97.4%97.5%97.5%97.5%97.5%
Partner C87.0%87.2%87.4%87.6%87.8%88.0%88.2%88.4%88.5%88.7%88.9%89.1%89.2%89.4%89.5%
Partner D95.9%96.0%96.0%96.0%96.0%96.0%96.1%96.1%96.1%96.1%96.1%96.2%96.2%96.2%96.2%
0 Replies