Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLUCIONADO

Dynamic moving average calculation

jaimonsk
Asteroide

Hello Experts,

 

My source data looks something like this. Here the divisor would be changing like 2,3,4,5...

DateCloseDivisor
21-12-2021172.9900052
22-12-2021175.6399992
23-12-2021176.2799992
27-12-2021180.3300022
28-12-2021179.2899932
29-12-2021179.3800052
30-12-2021178.1999972
31-12-2021177.5700072
03-01-2022182.0099952
04-01-2022179.6999972

 

Based on that we would need to create a new column called moving average in such a way that if the divisor =2 then Moving Avg would be like rows  1, 1+2, 2+3, 3+4 

ex:

DateCloseMoving AverageDivisor
21-12-2021172.990005172.9900052
22-12-2021175.639999260.81000452
23-12-2021176.279999263.77999852
27-12-2021180.330002266.4452
28-12-2021179.289993269.97499852
29-12-2021179.380005268.97999552
30-12-2021178.199997268.48000352
31-12-2021177.570007266.98500052
03-01-2022182.009995268.57500452
04-01-2022179.699997271.85999352

 

we would need to create a dynamic solution of moving average based on divisor. Can someone share an idea?

3 RESPOSTAS 3
mmenth
Bólide

Hi @jaimonsk,

 

I'm not sure how you got those moving number averages, but going by your other instructions I would suggest using a batch macro like the attached. It basically goes through each date in a loop and uses sorting, filtering, and summarizing to isolate the records used to do a moving sum/average.

 

Hope this helps!

 

Best,

mmenth

Qiu
20 - Arcturus
20 - Arcturus

@jaimonsk 
Can you confirm your moving average?

It doest look like what you described. 😁

Jishnu_K
Asteroide

Hi Jaimon,

I have created a Batch macro for this logic. Please find the attachment. 

Rótulos