Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

Replacing NULL values with previous year's values

gillburling
5 - Atom

I am trying to figure out how to replace values when an input on each line says to use another row's values.

 

So if the data looks like this:

 

IDsurvey_yearprev_value_indvalue
0012000n500
0012001y[null]
0022000n550
0022001n570

 

I would like it to look like this:

IDsurvey_yearprev_value_indvaluevalue_final
0012000n500

500

0012001y[null]500
0022000n550550
0022001n570570

 

I should also note that due to it being survey data, there are MANY "value" columns that would need to be replaced (if prev_value_ind is 'y', then they would all be null and all need to be replaced), so I might be better served by replacing the value column with the value_final column instead of creating new. If I'm creating copied "final" columns, I would end up with about 92 columns instead of 46.

5 REPLIES 5
fmvizcaino
17 - Castor
17 - Castor

Hi @gillburling ,

 

A Multi-row formula will do the trick.

fmvizcaino_0-1609958545175.png

 

 

Example attached.

Best,

Fernando Vizcaino

gillburling
5 - Atom

Thanks for the speedy reply, @fmvizcaino

 

It looks like I got it all to work after making sure the data set was appropriately sorted!

 

I want to make sure I'm applying this to this and other data sets appropriately. Could you point me to a resource or explain how the expression works? Particularly the [Row-1:value]?

fmvizcaino
17 - Castor
17 - Castor

Hi @gillburling ,

 

The multi-row tool works always related to the current cell, it is pretty much the same as creating an excel formula refering to the row above and drag the formula down.

 

https://community.alteryx.com/t5/Alteryx-Designer-Knowledge-Base/Tool-Mastery-Multi-Row-Formula/ta-p...

https://www.youtube.com/watch?v=xDYLxsQ8ibc

 

Best,

Fernando Vizcaino

gillburling
5 - Atom

What about if there are multiple years missing? Is there some way to nest this expression?

 

idsurvey_yearprev_value_indvalue
0012000n500
0012001ynull
0012002ynull
0012003ynull

 

should be:

idsurvey_yearprev_value_indvalue
0012000n500
0012001y500
0012002y500
0012003y500
fmvizcaino
17 - Castor
17 - Castor

Hi @gillburling ,

 

The multi-row checks row by row and fill them sequentially, so if the second row is null, it will replace the null with the value before and when checking the third row, the second row was replaced already, so it works as you need.

Example attached.

 

 

 

Best,

Fernando Vizcaino

Labels