My First Batch Macro - Football Petitions in the UK

by Andy Kriebel

This past week I had the pleasure of sitting in on Andre de Vries class with DS10 on iterative and batch macros. I typically schedule this class when I know I’m going to be gone, so I was excited that I finally got to learn how to create macros in Alteryx. I’ve understood WHAT they do for a couple years now, and now I understand HOW to create one.

Here’s was our Friday project assignment, we had from 9am until presentations at 1pm:

  1. Go to the website: https://petition.parliament.uk/petitions?state=all
  2. Find out how to grab the data from 1 petition
  3. Parse the data in Alteryx so it’s ready for Tableau
  4. Create a batch macro so the workflow can be run for how many petitions you give it
  5. Blend in an extra data set (geographies / political / etc.)
  6. Build a Tableau dashboard where people can filter for a particular petition.

Ok, game on! Based on advice from Andre, I started by prepping a single petition. I chose to search for all petitions related to football.

The main part of this workflow does just the prep job. It downloads the JSON for a petition, parses it, does some filtering, splitting, and reshaping. The beginning and the end bits are what convert this into a batch macro. Ok, the main macro done!

After a quick refresher from Conrad for how to set up the workflow that calls the macro, it was on to building the workflow that gets all of the pages that the search calls before feeding them into the macro.

This workflow starts with a single search result page URL, creates 10 more URLs, downloads them until it doesn’t find any more, parses the JSON of the results page to get each individual petition, runs that page through the batch macro (the football) and outputs the final result as a TDE.

Ok, it’s now about 11:30am and it’s time to create a viz. Within Tableau, I joined the petitions to shapefiles for each constituency, filter to only those in London, and built this simple viz. I insisted on presenting when the team did and enjoyed sharing how I built my macro. I find it to be really good practice to have to explain them out loud.

Click on the image below for the interactive version; there’s a mobile version too!