Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

compare data later in same table

Amourous12
6 - Meteoroid

Hi,

 

I need to read data later in a file and write it to a new column, is there a way to check data more than 1 line away using multi-row formula as I have used this to get the next/previous (previous year) line and see if it is different but it wouldn't be able to check further than the previous year, I would like to check if this has changed at all throughout the list as it can change multiple times. E.g. business column changed 3-4 times over 20 years

 

 

IDManagerYearBusiness
1tester2020tesco
1tester2019tesco
1tester2018tesco
1tester2017lidl
1tester2016lidl
1tester2015asda
1tester2014asda
1tester2013asda
1tester2012homebrand

 

 

Where I am checking previous business using multi row formula

IDManagerYearBusinessPrevious Business
1tester2020tescotesco
1tester2019tescotesco
1tester2018tescolidl
1tester2017lidllidl
1tester2016lidlasda
1tester2015asdaasda
1tester2014asdaasda
1tester2013asdahomebrand
1tester2012homebrandhomebrand

 

Expected:

 

IDManagerYearBusinessPrevious Business
1tester2020tescolidl
1tester2019tescolidl
1tester2018tescolidl
1tester2017lidlasda
1tester2016lidlasda
1tester2015asdahomebrand
1tester2014asdahomebrand
1tester2013asdahomebrand
1tester2012homebrandhomebrand

 

5 REPLIES 5
FinnCharlton
13 - Pulsar

Hi @Amourous12 , you can achieve this with some summarising and then re-generating the lost rows:

FinnCharlton_0-1683819552956.png

Hope this helps!

Amourous12
6 - Meteoroid

Hi @FinnCharlton, thanks this has worked, however I have thought of another example as this would more than likely come up in the future for similar tasks, what if the initial table had other columns which had different information in them that are not linked to the date or the Business column but are also required. Would this be possible using your method and joining your new table onto the existing table or no?

 

E.g

 

IDManagerYearColourreasonBusiness
1tester2020redN/Atesco
1tester2019redmost salestesco
1tester2018redmost salestesco
1tester2017redlack of saleslidl
1tester2016bluelack of saleslidl
1tester2015blueNo reasonasda
1tester2014redincrease salesasda
1tester2013orangeincrease salesasda
1tester2012orangelack of saleshomebrand

 

Also what if the years are missing a year, e.g 2014 next line 2012?

FinnCharlton
13 - Pulsar

@Amourous12 , yep you can join it back onto the original table instead:

FinnCharlton_0-1683879476158.png

 

Amourous12
6 - Meteoroid

Hi @FinnCharlton, thanks this has worked and sorry for the clarifying questions but what if the value appears multiple times in the table. for example if the business column had tesco again after lidl and another company after the second tesco, this would only show asda after tesco instead of lidl in the first set of rows

 

IDManagerYearBusiness
1tester2020tesco
1tester2019tesco
1tester2018tesco
1tester2017lidl
1tester2016lidl
1tester2015tesco
1tester2014tesco
1tester2013tesco
1tester2012tesco
1tester2011tesco
1tester2010asda

 

 

 

FinnCharlton
13 - Pulsar

@Amourous12 fair point, we can fix this with a multi-row formula to introduce an ID to each different instance of a business:

FinnCharlton_0-1683895103995.png

 

Labels