Alteryx Weekly Challenge #6 – Spatial Route

by Alex Hirst

My goal over the Christmas break, and perhaps an early new years resolution, was to start tracking these Alteryx challenges. I’ve seen many people across the Data School closing in on all 257 challenges completed and can understand how tracking these, and having that completion goal, will encourage motivation. It’s just one of those things I know I’ll regret if I don’t do it early.

Anyway! I have a fuzzy memory of how many I’ve completed and would estimate it’s around 40, although not all of these are saved on my computer and I could only tell you If I’ve done it when I open the starter workflow. I think the best strategy is to just start from scratch. As we're coming to the end of the day I thought I'd do a couple blog posts for my last challenges.

Alteryx Challenge #6 – Spatial Route

The benefit of starting from scratch is that some of these are quite quick. I’ve decided to explain this challenge as it was a Spatial challenge. Since we’ve only learnt Spatial relatively recently I think it’s important I consolidate my learning.

So here is the challenge (ignore the unrendered map).

We need to work out which Sales Rep has travelled the furthest. The strategy I would approach this with is to transform these points into single lines, for each sales rep. Only then, should we work out the distance of each line and sort accordingly. Luckily, they have given us a lot of what we need.

Building the Line

Let’s make that line. To make lines, are polygons, we need to use the poly-build tool. The Polybuild tool takes the spatial objects and can draw different objects to represent these points. This may be polygons to track how far you can cycle in 20 mins, or like in this case, lines to show routes taken.

In build method select sequence polyline as we want to measure the trip’s taken by the TripOrder Field to create the line. Group by the REP so we get distinct lines. Sequence by our Trip Order so our lines take the same route the REP had taken.

This will create our lines. I’ve highlighted Diana in a slightly lighter pink. Remember you can only view spatial maps in the browse tool.

Measuring Distance

Now we just need to measure the distance of these points. Some would consider using the distance tool but that should only really be used between points. Considering we want to measure a line, a simple Spatial Info tool (selecting Length (m)) will do the trick.

There we go! Stick around for challenge #7 coming up!

© 2022 The Information Lab Ltd. All rights reserved.