Alteryx Designer Desktop Discussions

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

Alteryx Lag Macro

OliverW
Alteryx Alumni (Retired)

Ever in need of "lagging" your data?

 

As I heard in many customer conversations, one feature people built for predictive models is a "Lag Feature".

 

Basically this means pulling a specific value from a specific field from the previous record into a new column of the actual record, looking like this:

 

image.png

 As you can see here, for the row 2, for column Lag-1 it pulled down the value from the previous row (1) .

 

You could achieve this generally by using one (or like in the above picture multipl) Multi-Row Formula Tools within Alteryx. Now, in order to be able to create as many "Lag Fields" that you need, I have created a Lag Record Macro. All you do is, you select how many rows before you want to start "lagging", how many rows you want to lag (essentially how many columns for lags you want to generate) and then select the Field (must be Numeric) which should be lagged, so basically a value field.

 

Once you have lagged you can also very easily calculate the difference between the actual row value and the lagged values for multiple columns (if you need to) by just using a "Multi-Field Formula" Tool afterwards.

 

You can download the tool in the Alteryx Gallery, it's a yxi Installer:

https://gallery.alteryx.com/#!app/Lag-Records-Macro/5d31b2aa0462d70db4d298f4

 

Hope this is useful for the one or other Alteryx User!

 

Best wishes
Oliver

6 REPLIES 6
joshuaburkhow
ACE Emeritus
ACE Emeritus
Ooh I can use this! Very nice!
Joshua Burkhow - Alteryx Ace | Global Alteryx Architect @PwC | Blogger @ AlterTricks
OliverW
Alteryx Alumni (Retired)

Sure welcome 🙂

Rasmuslarsen
5 - Atom

Hi OliverW

 

Thanks for this very useful tool!

 

Is it possible to add a way to group the lagged variables based on another column? 

 

OliverW
Alteryx Alumni (Retired)

Hi @Rasmuslarsen ,

 

that should be doable, now the Lag Macro is not locked, care to give it ago and share with the community when you are successfull? Happy to help if you run into any issues or questions.

 

Best wishes

Olli

Rasmuslarsen
5 - Atom

Hi @OliverW 

 

Thanks for your reply. I will try to iterate on the macro when I have some spare time 🙂 

 

Best regards, 

Rasmus

WadhaSH
5 - Atom

Hello,

Has this macro been taken down?

I can't seem to find it using the provided link nor through searching the gallery tab.

 

 

Labels