Hi champs,
I've spent time looking at discussions with similar questions but these seem to be a little too advanced for my understanding. What I would like to do is to apply the same procedures on multiple sheets in the same workbook, and then union them together.
I've learnt that using macro would be ideal for a situation like this (as opposed to have multiple input files), but could anyone give a quick example of how I could do this?
Attached is a simplified version of the workflow I did. Essentially I would like something below:
Some technical points to notice:
- In each sheet, the input starts from row 3
- I would like to have the country / tab name as a new column in the output
- Only selective sheets are used (e.g. "Do Not Use" tab in the workbook should not be used)
Could anyone shed some light on how I could use a macro to do this? Any help would be appreciated!
Best,
Pau
Solved! Go to Solution.
Hi @Paupau
In many cases, you can apply the same operations to the data from multiple files/sheets without requiring a macro. Your situation is one of those, since your input is a .xlsx file(so we can get the list of sheet names), and the schema is identical across all 3 sheets (so we can use a dynamic input tool).
Start by using an Input tool configured to return the list of sheet names and filter out the Do not Use sheet. Use a formula tool to replace "<List of Sheet Names>" with the actual sheet name in each of the paths. The Dynamic Input tool will read the file once for each the sheets and union the results. After extracting the Country name from the file paths returned by the Dynamic Input tool, continue with your original workflow. The only difference required is in the Transpose, where you need to include the Country as one of the key fields.
You should learn how to use Macros as well, since you'll eventually come across a situation where you'll need them. A great place to start is the "Getting Started" series by @EricWe and @SonaliM.
Getting Started with Standard Macros
Getting Started with Batch Macros
Getting Started with Iterative Macros
Dan
Thank you very much @danilang !
The workflow I posted is a simplified version of my actual work, which had different schema across the sheets. Therefore I would have to use a batch macro for that.
Any guidance on that would be appreciated! Thank you.
Best,
Pau
Hi @Paupau take a look at the following link for guidance on a batch macro that runs through files with different schemas: https://community.alteryx.com/t5/Alteryx-Designer-Knowledge-Base/CS-Macro-Dev-Reading-in-Multiple-Fi...