Alteryx Designer Desktop Discussions

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

Creating an moving running total

NicholasL
5 - Atom

I am trying to create a moving running total across a grouped by subset of data. The table below gives an example of the type of data set I am trying to summarise. I want to create a rolling "Last 12 Month Total" for the Value column, grouped by the Entity ID, Attribute 1 and Attribute 2 columns, where the total in the Running LTM Total column is the sum of all values in the group by set where the Month is within 12 months (or 365 days) of the month on the row. 

 

I am new to Alteryx and so I am hoping that I missing something quite simple, but I cannot figure out how to do it. 

 

Row IDEntity IDMonthAttribute 1Attribute 2ValueRunning LTM TotalNotes
112331-01-17BBBCCC55No previous month's values for this group by set and so the total is the value
212331-01-17BBBDDD1010No previous month's values for this group by set and so the total is the value
312331-12-17BBBCCC1015Row 1 matches the group by set and the month on row 1 is within the period 12 months before the month of the current row and so the total is row 1 + row 3 
412331-12-17BBBDDD1525Row  2 matches the group by set and the month on row 2 is within the period 12 months before the month of the current row and so the total is row 2 + row 4 
512331-01-18BBBCCC1525Row 1 matches the group by set, but the month on row 1 is not within the period of 12 months before the month of the current row and so it is dropped. Row 3 matches the group by set and is within the 12 month period and is included.
612331-01-18BBBDDD2034Row 2 matches the group by set, but the month on row 2 is not within the period of 12 months before the month of the current row and so it is dropped. Row 4 matches the group by set and is within the 12 month period and is included.



5 REPLIES 5
BenMoss
ACE Emeritus
ACE Emeritus

This is a fun problem to solve and your friend here is the generate rows tool.

 

For each row you need to identify the 12 months that you need to find values for. This can be done using as mentioned, the generate rows tool.

 

You can then perform a join against these 'needed values' and then perform your running total calculation.

 

Attached is an example using your sample data.

 

Lookback.png

 

Ben

NicholasL
5 - Atom

Perfect solution. Thanks for the quick response.

Ye_Olde_Baller
6 - Meteoroid

How would you do this if your Entities change? Say you have multiple groups in one data set and you want to do this all in one workflow?

Ye_Olde_Baller
6 - Meteoroid

Sorry for the crossed out font.

martinme8
5 - Atom

This worked perfectly for me too! Thanks Ben Moss - Awesome!

Labels