I would like to stop an iterative macro when a returned value doesn't exist in the evaluated field. In other words, in order to stop the iteration, I'd like to filter out all records going to the Macro Output when x from Field #2 does not exist in Field #1. I could Append x to all records and then compare the Appended field to Field #1 with a Formula. I was wondering if there is an easier way.
Solved! Go to Solution.
Hi Sbaker,
Not sure if I am able to get your question fully.
Does using join helps your situation - Join Field 2 with Field 1?
Thanks,
Rohit Bajaj
Hey @sbaker - happy Wednesday!
We may need to take a few iterations at this - not sure if I've interpreted your question correctly, but feel free to redirect or correct my understanding.
My understanding is:
- you have an iterative macro with 2 inputs
- You want to continue to iterate until the data in input 1 has no rows containing a value in input 2
Depending on whether you need a "contains" or a match - I'd either go with a formula (as you've said) or a simple join (where you take the left channel so that you don't matching rows)
If I've misunderstood or missed the mark - it may be worth mocking up what you're trying to achieve from the iterative macro (just drop the inputs and a proposed output with some notes on the need) onto a blank canvas and attach the workflow to this thread, and I'd be more than wiling to crack through this with you to find a solution.
Cheers @sbaker
sean
The macro is working properly, though I am curious if I'm approaching iterative macros correctly.
The macro is attached; "Start Here" is where I begin handling if 1) all records or 2) no records should be sent to the iterative output.
Your explanation is correct. I union the the evaluated results (which also go to the workflow output) with the input set (which then will go to the iterative output). I want to filter out all records to stop the iteration if the new value of the current iteration does not exist in the original set. I think this is different than the normal scenario where a macro iterates until all records are sent to the workflow output and the iterative output eventually runs out of data.
I used a combination of Append and Formula to evaluate if that value exists and then ultimately filter out all records if it doesn't.
Hey @sbaker
:-) now I'm very curious about the use for this macro, but appreciate that this may be company-confidential.
The short answer is that there is no sin or foul-play in using an iterative macro in this way - the power of the iterative macro is that it cycles until there are no more rows passed through - and an example of this would be where you look at moves in a board-game. You want to explore the move-tree X levels deep - which means that you terminate the iterations (by passing zero more records) when either:
- Iteration count = X (you've use the iteration count in your macro too) or
- any move is a winning move (similar to what you've done with using isnull([Path order]) as the beginning of a "finished" flag
This kind of depth search until you find one or more records that satisfies a condition is a good use of iterative macros - so no foul committed at all.
:-) That's not to say that there aren't different ways to solve the problem - one thing I've really been reminded of by doing the weekly challenges is that here's as many ways to solve a problem in alteryx as there are people tackling the challenges - but if your way works, I say you're on the right track.
Have a good Thursday
Sean