Alteryx Designer Desktop Discussions

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

Generate additional rows based on condition

jpena
5 - Atom

Hi guys,

Need your help solving an issue here.

 

I have this input:

 

ProductYearMonthValue
A2018120.6
A201936.4
A201949.7
A201977.3
B201888.5
B201897.3
B2018114.0
B201924.9
B201941.9


And I need to turn it into the following output:

 

ProductYearMonthValue
A2018120.6
A201916.4
A201926.4
A201936.4
A201949.7
A201957.3
A201967.3
A201977.3
B201888.5
B201897.3
B2018104.0
B2018114.0
B2018124.9
B201914.9
B201924.9
B201931.9
B201941.9

 

The values in bold and italic are the new rows I want to generate.

 

Basically, what I need to happen is that for a given product I want to have all months represented from the starting period (Year and Month) until the last one and for that I need to add rows. Besides that, the newly generated rows should get the value (field [Value]) from the older period.

Thanks in advance!

2 REPLIES 2
danilang
19 - Altair
19 - Altair

Hi @jpena 

 

Here's a workflow that does what you're looking for

 

w.png

Start by building a Start of Month (SoM) column from your input.  Summarize by product to find the min and max SoM.  Use the Generate Rows tool to fill in all the months.  Join back to your input data to pick up the Values that are there.  A Multi-Row tool will fill in the values but it only works from the top of the dataset set down.  Since you want to fill from the bottom up, sort by product and SoM descending first.  Fill the missing values and the next formula tool fills in the missing Year and Month fields.  Re-sort by product and date ascending and you have

 

r.png

 

Dan

jpena
5 - Atom

Solved. Tks!

Labels