Alteryx Designer Knowledge Base

Definitive answers from Designer experts.

Find Nearest: Locate the Closest Retail Location to a Customer

Alteryx Alumni (Retired)


You are in charge of marketing for Joe’s Bike Shop, a Colorado-based chain of bicycle shops. A new list of potential customers (DemandLoc.yxdb) has come into the system and you want to be sure that the closest location of a Joe’s Bike Shop (ExistingLoc.yxdb) within a reasonable driving distance (in this case, 20 miles) be advertised to the Potential Customer.


As always with Alteryx, there are many ways to approach this problem. Since our files of Potential Customers and existing locations of Joe's Bike Shop contain spatial objects (points), we can take advantage of the Find Nearest Tool. Though a number of other spatial processes could be used to handle this analysis, this scenario is a great opportunity to use the Find Nearest Tool because it:

  • includes two anchors for data input, which removes the obstacle of complex data arranging;
  • Accepts a distance criteria (Joe's Bike Shop must be within 20 miles of our potential customer), which eliminates the need to create Trade Areas around my existing location of Joe’s Bike Shops;
  • Calculates distance (or Drivetime) and direction, metrics I’d normally use the Distance tool to obtain and;
  • Allows a user to specify the number of closest spatial objects to identify, making the ol’ Sort and Sample trick unnecessary!

Let’s get started!

We have two input data files, the locations of Potential Customers (DemandLoc.yxdb, 3294 records) and the existing locations of Joe’s Bike Shops (ExistingLoc.yxdb, 6 records). Since we want to find the closest (within 20 miles) Joe’s Bike Shop location to a Potential Customer, we’ll set the Potential Customers file as the Target Input and the Existing Locations as the Universe input:


Then, we’ll configure the Find Nearest Tool’s parameters. Select the Spatial Object field for the Target and Universe inputs. Determine the number of points to find and specify the maximum distance* between a Target and Universe point. Note that the Find Nearest Tool also allows us the opportunity to re-name and re-order fields from incoming data, as well as select/de-select new fields generated in the Find Nearest Tool (FindNearestRank, DistanceMiles, and Direction).

*Users with the Spatial Data Bundle may also select Drive Time or Distance and the TomTom dataset to calculate.


The Find Nearest Tool has two output anchors, one for matched (M) Target inputs and another for unmatched (U) Target inputs. According to our analysis, 2341 of our 3294 potential customers have a Joe’s Bike Shop location within 20 miles of their location. The remaining 953 Potential Customers are outside the 20 mile distance.

In the event that two Universe objects are the same distance from a Target object, the Find Nearest Tool will output multiple matches for a Target Object. Since we specified that one Joe’s Bike Shop should be found per Potential Customer, we’ll verify that a Potential Customer has not matched to more than one shop location using a Unique Tool (see attached workflow).

Looking to optimize your Find Nearest Workflow? Check out this articlefor tips!