community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
Upgrade Alteryx Designer in 10 Steps

Debating whether or not to upgrade to the latest version of Alteryx Designer?

LEARN MORE

Looping and dynamically changing output

Highlighted
Meteoroid

I have a dataset that looks like(these numbers and columns are random)

Period A B C D E F G
1 1 2 3 4 5 6 7
1 11 22 33 44 55 66 77
2 111 222 333 444 this should be 77    

 

Now , I am calculating column F & G using certain conditions from the prior columns, once I have calculated values for all the columns for a particuar period, I procced to the next period where value for column E equals that of column G in previous period.

 

And, then again I calculate the values of F & G for period 2 . I want to repaeat this process for multiple periods.

 

I believe batch macro is the solution but I am unable to find a way to use it in this case, any approach without using a macro would also be helpful

Magnetar

Just for clarification, what is the starting state?  No column F and G, as they are derived by your workflow?  But what about column E?  For period 1, it sounds like E is already there?  But not there for period 2?

 

Anyway - a starting state along with the desired end state will help us determine various solutions.

Meteoroid

Yes for period1 values for column E are available but not for any future periods, as they are value for E at t is equalt to value for G at t-1

Also, is there a way I can use the expression 

 

 

IF [Period]= 2 THEN [G] IN ([Period]=1) ELSE [E] ENDIF

 

Although its not giving the desired result, i want to use something similar to a where statement

Magnetar

This is basically row-dependent iteration, which is tricky. Here's a nice write-up and various iteration tools in R: http://nicercode.github.io/guides/repeating-things/, and even in R, where myriad "apply" functions can do almost anything you can imagine, they admit that a regular "For" loop works great for row-dependent iteration, "where the output of one iteration depends on the result of the previous iteration."

 

In that light I went ahead and created a simple call to R that performs a For loop to fill out the input data set. I've attached the workflow. Hopefully this is easily modified to fit your specific needs.

 

(With all that said - I'd also be very interested in someone showing a solution using only Alteryx tools.)

 if i understood correctly,

 

here is a way to do it using Multi row formula 

Labels