Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

API Iterative Macro - Auto Update Dates

mhart
7 - Meteor

I am pulling data from a website via an API. The API only allows me to query 15 days at a time. Currently, I am copying/pasting the input and download tool and manually updating the start/end date for the 15-day increments, which I have to do to get 6 months worth of data. I also have to do that for 30-40 locations by updating the "Organization ID" query parameter. I'm trying to figure out a way to automate this process, where the current date is my  "end date", and it makes the start date 15 days before that, and so on until it goes back 6 months. Then I'd want to join all those iterations and parse out the XML to a readable format. Any suggestions would be appreciated, thank you. 

7 REPLIES 7
JoeS
Alteryx
Alteryx

Hi @mhart 

 

I have built a batch macro rather than an iterative to do what you need.

 

Attached is a packaged workflow that builds the rows you need for the batches and then the batch macro is incorporated as well.

 

I haven't run and tested it so I don't use up your runs! But it should be good to go.

 

Edit: Great spot by @MichalM , which made me also realise the format of the dates weren't how the API was expecting them. Attachment updated with both bits!

MichalM
Alteryx
Alteryx

@mhart 

 

@JoeS's solution should work. You'll probably need to add one more formula to get the end date change as well to follow the 15 day pattern.

 

generate-periods.png

mhart
7 - Meteor

Thanks for the quick reply, Joe. I am getting an error when I import your package. I have the most up to date version of Alteryx. I clicked Okay on the workflow below, but nothing popped up. I did see when I tried to insert a macro that the batch macro was available, but it said that it was not a valid macro. I was able to open up MichalM's workflow. Any suggestions? 

 

clipboard_image_0.png

JoeS
Alteryx
Alteryx

That's odd, I am using 2019.2.7.63499.

 

I have attached the workflow and the macro separately to see if that makes any difference.

mhart
7 - Meteor

That helped and I was able to download/import both. 

 

I'm not sure if I'm just missing something or doing something wrong (this is my first time doing a batch macro in Alteryx). I don't know how to troubleshoot this. When I run the workflow in the "Batch API" tab, I get results with the values in the download tool. However, when I then add the macro to the workflow with the dates in 15 day increments, I'm getting an error and I'm not sure what to do next. 

clipboard_image_0.png

clipboard_image_1.png

JoeS
Alteryx
Alteryx

I'd recommend adding an extra output from the macro straight after the download tool. This will then give you what's returned and help you debug from there.

 

Another top tip is to make sure you have a browse tool after batch macros, as it can cause Alteryx to stop processing batches if there is no tools after a batch macro, thus it assuming you don't need the results.

mhart
7 - Meteor

got it to work, thank you so much for your help! 

Labels