This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
It's the most wonderful time of the year - Santalytics 2020 is here! This year, Santa's workshop needs the help of the Alteryx Community to help get back on track, so head over to the Group Hub for all the info to get started!
Trying to perform a moving average over a range of dates for a specific value. In the example data set attached, the range between Finish and Start Date-Time is 15 days. Step one involves a moving average using one of the value columns (i.e. Value1) using values in rows between the Finish and the Start dates. You will see there is not a consistent number of records to average over by date. This step I can't quite figure out. The output must calculate back from the Finish Date over the last 15 days. I.e. For row 1, the average is equal to just the value for that day. Once there are over 15 days, use data only within the 15 day window.
StartDate is not required as the 15 could be in a formula. Any hints?
Step two requires I then perform across all rows (Value2, Value3) but that can wait till I figure out step 1.
There are a few ways to achieve the desired result here, I choose to use a Batch Macro. What this macro does is for each day (control parameter), it matches all the relevant date records (last 15 days), and averages all the values during that time period.
Check out the attached solution and let me know if this works for you.
Your solution had the same problem I struggled to accurately calculate averages over a group. It is not simply taking averages of averages. If one changes the 'Count = 1' to a summarized count of the number of entries for the day, your solution is closer but still not accurate. Here is a link to a more rigorous explanation of why an average of averages is not correct. I did learn one technique from your solution - so thanks.