How to calculate the 30-day rolling average?
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi,
Could someone please help me calculate the 30-day rolling average of the "ratio" column by country for each day?
I have tried using the multi-row formula, but it's a bit confusing, and I'm not sure if I'm doing it correctly. Any guidance would be appreciated.
Thank you!
Attached sample of the data:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hey @AKPWZ
Here's how I'd do this:
The multi-row method can look back 30 rows, but that's not the same as 30 days in your data (it's also a massive pain to write such a long formula).
By scaffolding your dates to go back 29 days and then join your data onto itself with that, we can average that joined data to find an actual 30 day moving average.
If you need to find this average within countries (i.e. the 30 day moving average in DM) , then include country as a joining condition, but I've assumed that's not what you're after here...
Hope that helps,
Ollie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @OllieClarke Thank you Thank you so much
I just want to confirm that I understood the workflow you shared correctly. This workflow will:
Create a Date Range: For each date, look back 29 days to include a total of 30 days, including the current day.
Join Data: Merge your data with itself based on this 30-day period.
Calculate the Average: For each date and for each country, compute the average of the "ratio" values over these 30 days.
As you asked (If you need to find this average within countries (i.e. the 30 day moving average in DM) , then include country as a joining condition) and If that’s what I need, what changes should I make to the existing workflow?
This will provide a 30-day moving average for the "ratio" column.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@AKPWZ
Yeah, so the generate rows makes a lookup of all the dates which would be in the 30 day window
We then use that lookup to join on the relevant ratio values
Then you can avg the Right_Ratio column to find your 30 day moving average.
Does that make sense?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
HI @OllieClarke
If I need to find this average within countries (i.e. the 30 day moving average in DM) , then include country as a joining condition.
so in the joining tool I also check country data to achieve this, right? (Attached the screenshot)
Also could you please tell me what exactly DM is? Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Exactly like that screenshot!
DM was an example value in your country column (maybe Dominica?)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @OllieClarke thank you once again
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Happy to help @AKPWZ - would you mind marking my response as a solution, so the community can more easily find it if they've got the same question?
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hey Ollie,
On similar lines to above query, I have this dataset and I would like to calculate 12 months rolling average of Volume_LTE_GB (columnD) per USID (columnC). Can you please guide me through this.
Thank you in advance.
