General Discussions

Discuss any topics that are not product-specific here.

How to loop a list of dates that feeds into an sql query in a workflow

AmSu
5 - Atom

Hello,

 

I was wondering if anyone can help me please. I have a workflow that links to a query which links to a database. In the query there are some dates, which each month I need to update - they are the start and end dates of a month. I am trying to find a way to produce a macro that can go through a list of dates/months, running the query/workflow for each month one at a time, and producing an output that combines all the months together.

 

The reason I want to do this is because I have a complex query that constantly changes, and I constantly need to re-run data for the last 2/3 years - and it's very time consuming running it one month at a time each time I make a change to the query. I have provided an example workflow and how I would like the output to look. For privacy reasons I have not been able to provide the original query, so the attached may seem very simple, but the attached should show what I'd like to be able to do.

 

Can anyone help please? I haven't used macros before, and I can't seem to find a similar solution on here that loops dates through a query -  I hope I have provided enough information but please let me know if you need any additional info - thanks!

2 REPLIES 2
caltang
17 - Castor
17 - Castor

Hi @AmSu - I'm not sure if I follow entirely, but what you're trying to do is change the dates manually?

 

You can use this:

 

image.png

 

Just put two dates, and it will create the rows itself for each month - start and end of each month accordingly. So just pick the start date, and pick the end date of which you want it to stop - in this case I've also coded it so that it starts from whenever you pick, and ends exactly at the last day of that particular end month you have in mind.

 

Then it just goes in the formula tool and to the In-DB tool as is.

 

Not sure if it helps, but you don't need a macro for this.

 

Calvin Tang
Alteryx ACE
https://www.linkedin.com/in/calvintangkw/
Qiu
20 - Arcturus
20 - Arcturus

@AmSu 
It seems to me that you need a Batch Macro, which will send your data one row each to the macro and the result will be unioned at the output anchor.

Try to seach the documentation or sample workflow of Batch Macro.

Here is a quick sample.

0310-AmSu-A.png0310-AmSu-B.png

Labels