Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
Check out our powerful new search update! You can read more here. Please let us know if you have any feedback by creating a topic here.

Finding nearest with multiple selection criteria

Alteryx Partner

I have 2 sets of locations, and currently have identified all the nearest points within 200 metres. Is it possible to then make this selection criteria more comprehensive, to say that "if [record ID] = "rural area" then [nearest point] within 200 metres elseif [record ID] = "urban area" then [nearest point] within 50 metres". 


Understand that this is not a proper line but just to explain the logic I hope to create. Hope to get some help!


Hi NewUser,


I'm not aware of anything for exactly what you want, but could you filter your record id into the two type of area first and then join with your two different distance requirements as two separate tools? Or is there some other limitation meaning you can't do this?


If you could attach your workflow with some (if need be) sample data, I could take a look.




Hi @NewUser123,


One way to achieve what you want is by using batch macros.

If you are not familiar with the, here you can find a training on how to build one


The concept is pretty simple:

- you package the logic of your search (find nearest and some filters) in a (batch) macro

- you can make the logic within the batch macro configurable, by using the Control Parameter tools

- your search criteria become an input of your batch macro

- the external workflow (the one in which you use the batch macro) will pass one record at a time to the batch macro with a set of criteria (say, 'rural area' and '200 mt' first, then 'urban area' and '50 mt', and so on)

- you'll get the final results stacked on top of each other at the end of all 'iterations'


This would be your external workflow:


And this is how the batch macro will look like (I've just added a few tools here to show you the principle).



In my example, the Control Parameter and the Action Tool associated with it, will change the hard coded values within the filter and the Find Nearest tool with whatever parameter gets passed in from the external workflow.


Hope this makes sense and I'd strongly recommend you to look into batch macros as they come very handy in lot of different situations.