Alteryx Designer Desktop Discussions

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

To copy data from previous months

Polite123
8 - Asteroid

Hi Team,

 

I would like to get some data manipulation done in alteryx.

 

Input:

MonthsValue
Jan 3
Feb4
Mar5

 

Output:

 

MonthsValue
Jan 3
Feb4
Mar4

 

If I run the workflow for March month using calendar,it should have value from Feb month.

Can you please help?

 

Thanks

 

3 REPLIES 3
Kenda
16 - Nebula
16 - Nebula

Hello @Polite123 

 

I attempted to build something that would accomplish what you're looking for. I changed the months to Oct, Nov, & Dec to test. 

 

First I created two new fields using a formula tool.

 

Month Num (the number of the month from the Months field): 

tonumber(substring(DateTimeParse([Months],"%b"),5,2))

 

Diff (the difference between the month number in the data and the current (today's) month number:

[Month Num] - tonumber(DateTimeFormat(DateTimeToday(),"%m"))

 

 

Kenda_0-1637755679891.png

 

 

From here, just use a multi-row formula tool to update the Value field based on our new Diff field. If Diff is equal to one, update the current row with the previous row's value:

iif([Diff]=1, [Row-1:Value], [Value])

 

 

Kenda_1-1637755847300.png

 

 

 

Polite123
8 - Asteroid

@Kenda -Thank you for quick reply.

 

With some modification in data,can the below be achieved?

 

Input data:

 

Months CategoryValue1Value2
JanuaryA32
JanuaryB43
JanuaryC64
FebruaryA67
FebruaryB78
FebruaryC59
MarchA51
MarchB62
MarchC73

 

Output data:

 

Months CategoryValue1Value2
JanuaryA32
JanuaryB43
JanuaryC64
FebruaryA67
FebruaryB78
FebruaryC59
MarchA67
MarchB78
MarchC59

 

If we run the workflow for the month of March,it should give values from February corresponding to each category.

Similarly if we run for April,it should give data from March and so on.

 

Any help is much appeciated.

Thanks in advance

Kenda
16 - Nebula
16 - Nebula

@Polite123 

 

Yes this is definitely possible. I think the key here is to add a sort tool before the multi-row formula tool, though. First sort category ascending then month num ascending. This way the categories are grouped together sorted by the months.

 

Kenda_0-1637759010933.png

 

 

Then you'll just need two multi-row formula tools, one to update each value field. 

Labels