Hi - I'm trying to build a for loop in Alteryx. Has anybody been able to do this without having to use a macro? It would be great if I could loop through a list and call on a container to be initiated but I see Alteryx has some limitations.
@deterrazas What is the issue to use Batch Macro or Iterative Macro?
@deterrazas I think we need more information in order to answer your question. The best would be you give some sample data as input and desired output.
Good question! Just trying to get a better understanding of why macros seems to be the only way to implement a loop in Alteryx. Coming from a Python background - it seems tedious to create an additional workflow and then bring it in just to achieve the loop behavior i am wanting since its something that I've achieved directly with less steps in code. But it may be the way Alteryx runs & there may be design reasons behind it. Any help is greatly appreciated! :)
Thanks for responding! Totally understand & agree!
So I'd like to keep this as general as possible so I'm going to make up a workflow scenario. Let's say there's a Doggy Day Camp & each dog is given a behavior score each day. A report card for each dog is given to the owner every so often to give an idea of how their dog is behaving.
Goal: I'd like to be able to loop through every distinct name in the list and for each name —> go through the container which will do some math, give a status, do some formatting…etc —> then output a report card. My desired output would be 5 report cards to give to each dog's owner.
A for loop would be best (for x in this list do this) for this but it seems a macro would be the only solution however I would love to know if anyone has been able to generate a loop without a macro.
Any help is greatly appreciated! :)
@deterrazas I see, well in Python, or any other coding language, you will use FOR or WHILE to create a condition that will indicate to continue doing it until that condition met. As you are creating workflows in Alteryx, if you want to have a condition that tells is do it again and again you need to take that part so it will be a stand alone WF and get it run over and over again, that is why a macro is needed, as it enabling you to have a workflow within a workflow.
Yes exactly! I've created another workflow for my workflow but then I'm like wait a minute in python this would be soooo much simpler. I'm so curious to learn what exactly is the limitation in Alteryx? There just has to be a way outside a macro but if macro is the only way then it's the only way. 😄
@deterrazas I see, well in Python, or any other coding language, you will use FOR or WHILE to create a condition that will indicate to continue doing it until that condition met. As you are creating workflows in Alteryx, if you want to have a condition that tells is do it again and again you need to take that part so it will be a stand alone WF and get it run over and over again, that is why a macro is needed, as it enabling you to have a workflow within a workflow. I'm not sure if you need a macro, as you can create multiple conditions with the Formula tool, doing all the same on all the entries. As you have the dog name you can use it in the output path as a variable which will create a separate file for each of the dogs. Which loop you actually required to do? You can create many logics to check the data on the same time leaving Yes/No flags, such as: won beauty competition, won skilled competition etc. Or you can create one workflow with all the data checks, pack it as a batch macro and then get Alteryx doing it for each dog separately. Which loop is required, as you might not need it in Alteryx, and the is the beauty of Alteryx
Yes, but my concern with that is scalability & maintainability. What happens if a new dog joins Doggy Day Care? 🐕️ I'd want the workflow to automatically iterate through that updated list & run the exact same analysis/process for each dog dynamically without having to go in & add logic (or create another workflow). Does Alteryx just abstract away from traditional programming structures in favor of workflow modularity?
@deterrazas If the dogs are part of the data then no need to worry about it, it is just another variable therefore Alteryx will know what to do based on the available data.
@deterrazas basically, beside the macro. we can use append / transpose /crosstab / summarize / generate rows + multi-row to avoid the macro way.
i see that alot in the Advent of code (alteryx version) these years. and for your case, we can use the transpose (or unpivot) to get dynamic total for each group. then use join to add the new total column to the original data (We can use crosstab here but it will change the column sorting)
then use output tool to csv for different dog cards
workflow