## Mapping in Tableau - User Adjustable Hexbins

by Harry Beardon

Today I will show you how to create a user adjustable hexbin when mapping in Tableau. Essentially it will group points on your map within a specified radius. This technique can be useful when you have a lot of points on your map and you want to reduce the marks in the view to clean it up a little, without also having to sacrifice that information.

I am just using some data on rat sightings in New York, but the steps are easily replicated with any data of your choice as long it has:

· A Longitude field

· A Latitude field

· A field to be used as your measure

First lets create our hexbin adjuster parameter to allow the user to adjust the hexbin dynamically later- this is a simple parameter that allows the user to enter a numeric value:

From here, create a calculation to create our Hexbin X. The function we’ll be using is ‘HEXBINX()’. Within this function you have to specific two numbers separated by a comma- our first will be our Longitude field and our second will be our Latitude. To integrate the dynamic hexbin size adjuster, lets also multiply each of our numbers by the value entered in our ‘Hexbin Adjuster’ parameter.

Repeat this step for Hexbin Y. The method is almost identical except instead of the ‘HEXBINX()’ function we use ‘HEXBINY()’.

After this, change the data type of our new Hexbin X calculated field. Choose a geographic role and make it Longitude. Repeat this step with our Hexbin Y calc, except make this Latitude instead.

Our last step is to drag our Hexbin X onto Columns and Hexbin Y onto Rows. This should give you a view similar to mine. We can then interact with the parameter on the right to change the size of the bins.

Start by creating a new Calculated Field and create a Boolean statement based on meeting a condition in your measure value. For me this was different amounts of Rat Sightings.

Find some emoticons on google that you want to represent your different conditions – preferably have them transparent backing so we can color them too. Place these in your ‘My Tableau Repository’>’Shapes’ Folder in file explorer. Create a new folder called “Emojis” or something similar.

Hold CTRL and click and drag ‘Hexbin Y’ on Rows next to itself – this should give you a dual axis like so:

Change the first Hexbin Y field on your marks card to a circle, and drag your Boolean condition statement to colour

Change the second Hexbin Y (2) field on your marks card to a shape and drag your Boolean condition statement to shape, open the shape menu and assign the emoji’s you downloaded earlier

This should give you a result similar to this:

That’s all for this blog post! I hope you found this helpful

Harry Beardon

Mon 26 Apr 2021