Is it possible in alteryx to use a for loop in the python tool to run an entire workflow multiple times for every item in that for loop?
So for example, I have a workflow that is only designed to work with 1 week (i.e. one specific date) of data. But now I have a a dataset that contains multiple dates so the workflow wont run. One solution is for me to use a filter tool and only select a certain date and run the workflow. Then change the date, and run it again for the next date etc.
However, I would like to know if it is possible to use a simple for loop in the python tool to iterate through all the dates and run the entire workflow for every df.loc dataframe for example. In python, I would think of this as packaging the entire workflow into a function and then just saying something like:
dates = [list of dates]
for date in dates:
df = df.loc[df[date_column]==date]
my_function(df)
where my_function contains some workflow that will write output to a database. However, in this case, I want to continue working with the output of my function in alteryx designer because that is where the current workflow exists at the moment. So for every slice of the DF I want to run my entire alteryx workflow.
Is there a way to do this using the python tool?
I also saw https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Python-Tool-Write-Streaming/td-p/40123... and seems like this was not possible when this thread was opened in 2019.
Solved! Go to Solution.
hey @mgimpel
The ideal solution is much simpler than this! You can do all of this with a batch macro. Batch macros runs one time for each record in the data supplied.
There is a good resource on learning batch macros here:
https://community.alteryx.com/t5/Alteryx-Designer-Knowledge-Base/Getting-Started-with-Batch-Macros/t...
If you need any help with this, let me know.
Cheers,
TheOC