Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Dynamic String for Batch Macro

Bonediggler
9 - Comet

Experts - 

 

The issue:

 

1) I have some sql (someone else wrote) that can only execute for one month at a time 

2) I need to run 24 months of data with this code (i.e. the query needs to be run separately 24 times, one month at a time)

3) The 24 months are dynamic.  For example if I ran the macro this month I would start with June 2017, next month I would start with July 2017 and so on.

4) I am writing a batch macro to process the sql by month and output to Excel and am currently feeding in the months via a text input tool

 

Is it possible to somehow dynamically generate the list of month values for feeding into the macro?

 

Thanks in advance!!

2 REPLIES 2
fmvizcaino
17 - Castor
17 - Castor

Hi @Bonediggler ,

 

For that, I think it would be easier to use a dynamic input tool. That way you can dynamically modify your query. See the topic below.

https://community.alteryx.com/t5/Alteryx-Designer-Knowledge-Base/Modifying-SQL-Query-using-the-Dynam...

 

Let me know if that works for you.

Best,

Fernando Vizcaino

seven
12 - Quasar

@BonedigglerIt seems like you already have the dynamic replacement part set up using a macro and all you really want is to create a list of 24 months including the current month.

 

Use a Generate Rows tool to create the current date and trim it to the beginning of the month.

seven_3-1588795927915.pngseven_4-1588795939023.png

That yields:

seven_2-1588795903340.png

Use the current month in a subsequent Generate Rows tool to start with the month 23 months back and add a row by adding a month until we reach the current month.

seven_5-1588796052616.png

seven_6-1588796067317.png

 

That yields:

seven_7-1588796113491.png

Use a Select tool to reduce the data by removing the current month field, yielding your result:

seven_0-1588795789614.png

 

This is the workflow and I have attached it below as well.

seven_8-1588796201328.png

 

Labels