HI All,
I am new to Alteryx and I am trying to create a loop/iterative macro of sorts. I am creating a workflow that has multiple SQL queries that i run using "Text Input" into a "Dynamic Input" which when run together and after some processing (summarize, table, report text, layout) gets sent out via email.
Let's say for the sake of this example, this group of SQL queries/dynamic inputs needs to be run 5 different times, one time for each different input in the WHERE statement of the SQL query, for example I have 5 names I want to iterate the entire workflow through:
SELECT
field_a,
field_b,
field_c,
FROM table_a
WHERE customer_name = 'placeholder'
SELECT
field_d,
field_e,
field_f
FROM table_b,
WHERE customer_name = 'placeholder'
I use the dynamic input tool to replace 'placeholder' with the name i have in the Text Input linked to the dynamic input.
Is there a way to add all 5 of my names into the Text Input so that the Text Input has 5 rows and that SQL queries above runs 5 different times, once for each name? In the end, I also need to send an email to 5 different people, based on the results of the queries using the 5 different customer names. Is this possible too?
My current solution is to copy paste my entire workflow 5 times and run it all at once, but I was wondering if there was a more efficient solution. Thanks in advance for the help!
Hi @jonathan710,
What you are trying to do looks more like a Batch macro than an Iterative Macro. Instead of a Text Input and Dynamic Input tools, your Batch Macro would have an Input Data tool with the Control Parameter (via Action tool) attached to it. The workflow would feed a list of names into the Batch Macro that would change the customer name for each batch (replace the 'placeholder'). The macro could also contain a list of email addresses and customer names and using the Email tool send an email to each customer. Let me know if you need assistance setting up the Batch Macro.
Thanks for the reply. I understand in principle what you are saying but I am having difficulty with the execution and implementation of the macro since I have never worked with any macros before.
Hi @jonathan710,
Attached is a sample batch macro workflow. The Email tool in the batch macro is Disabled in a Container as it would error without real email addresses. If you set the "To" box in the Email tool to the Email field, it will send out a separate email to each recipient. Try running this with the email disabled first to see how the data flows through the Batch macro. If you still need assistance, send me a private message through Alteryx Community (hover on my name and click "SEND MESSAGE")
I am trying to attach a screenshot of my workflow but it isn't allowing me to do that. On the far left, I have my text input, which currently just has 1 "customer name" in it, linked to 11 different SQL queries all utilizing the "Customer name" in a WHERE statement. I just need my workflow to run 10 times, once for each customer name I have without having to copy paste my workflow 10 times.
I have 10 different customer names i need to loop through this exact workflow with, and at the far right, i have an email function that has to have unique to/from/cc/bcc recipients per customer name, as I am sending each customer their own data and not anyone else's. Other than that, everything about each workflow is the same from customer to customer.