Tableau Function: HEXBINY

Category: Number Functions

The HEXBINY() function in Tableau is a spatial binning function that returns the Y-coordinate of a hexagonal bin containing a specific data point.
It is typically used alongside the HEXBINX() function to create hexagonal binning visualizations, which simplify and aggregate large volumes of spatial or scatter plot data into visually meaningful hexagon-shaped clusters.

Purpose

The main purpose of HEXBINY() is to help you aggregate dense spatial data (such as coordinates or numeric pairs) into hexagonal bins, making it easier to visualize and analyze patterns, trends, or data density.
When used with HEXBINX(), it transforms continuous spatial data into discrete hexagonal coordinates — a technique widely used in heat maps, density plots, and geospatial analysis.

Type of Calculation

  • Category: Spatial / Numeric Aggregation

  • Operation: Converts a numeric coordinate (Y-value) into the Y-coordinate of the hexbin center that contains it.

  • Works together with HEXBINX() to generate a 2D grid of hexagonal bins.

Practical Use Cases

  • Density Visualization: Represent high-volume data in a condensed and visually interpretable form.

  • Spatial Analysis: Group nearby points (e.g., geographic locations) into hexagonal clusters.

  • Scatter Plot Aggregation: Reduce overplotting in scatter plots.

  • Heatmaps: Create density-based heatmaps using color or size for aggregated values.

  • Outlier and Trend Analysis: Identify regions of high or low concentration in two-dimensional data.

				
					HEXBINY(expression)
				
			
ParameterTypeDescription
expressionNumeric (scalar, table, or column)The Y-coordinate value or field to be converted into the corresponding Y-coordinate of a hexagonal bin center. Typically used with a measure like [Latitude] or [Y Position].

How It Works?

The HEXBINY() function divides the Y-axis into a hexagonal grid, where each hexagon represents a discrete spatial bin.
Tableau automatically computes which hexagon a given data point belongs to, based on its numeric Y value, and returns the Y-coordinate of the hexagon’s center.

Conceptually, HEXBINY() applies a transformation that groups nearby Y-values into the same hexagonal “band” or region.

When paired with HEXBINX(), each data point is mapped into a hexagon on a 2D tessellated grid (similar to a honeycomb pattern), which can then be aggregated, colored, or sized to represent various measures such as count, average, or sum.

Simplified Mathematical Principle:

For a given coordinate (x, y):

  • HEXBINX(x) → returns the X-coordinate of the bin’s center.

  • HEXBINY(y) → returns the Y-coordinate of the bin’s center.

Each hexagon has a fixed size and height-to-width ratio (approximately √3:2), allowing uniform tiling across the 2D plane.

What Does It Return?

  • Type: Floating-point (decimal) number

  • Meaning: Returns the Y-coordinate of the center of the hexagonal bin containing the given data point.

  • Used together with HEXBINX() to plot the corresponding X-coordinate.

When Should We Use It?

Use HEXBINY() when:

  • You’re working with scatter plots that have too many points to interpret individually.

  • You want to visualize data density instead of individual observations.

  • You’re aggregating geographic or coordinate data into bins (for example, when working with latitude and longitude values).

  • You need to enhance performance by reducing the number of visible marks on a visualization.

  • You want to calculate per-bin metrics, such as average sales, average temperature, or customer count per area.

Basic Usage

				
					HEXBINY([Y])
				
			

Description:
Returns the Y-coordinate of the hexagonal bin center that contains each data point’s [Y] value.

Y ValueHEXBINY(Y)
2.42.3
2.62.3
3.13.0

Here, multiple data points with similar Y-values are grouped into a single hexbin centered around 2.3 or 3.0.

Column Usage (Scatter Plot Example)

You can combine HEXBINX() and HEXBINY() to create a hexbin plot:

				
					HEXBINX([Longitude])
HEXBINY([Latitude])
				
			

Use these calculated fields as the columns and rows of a scatter plot.
Add a COUNT() aggregation (or other measure) to color the bins based on density or intensity.

Result:
A hexagonal density map where each hex represents an area containing multiple data points.

Advanced Usage – Combine with Aggregations

You can calculate an average metric (e.g., average profit) per hexbin:

				
					{ FIXED HEXBINX([X]), HEXBINY([Y]) : AVG([Profit]) }
				
			

This Level of Detail (LOD) expression groups data points by their hexagonal bins and calculates the average profit per bin.
It’s especially useful for spatial heatmaps and performance dashboards.

Tips and Tricks

  • Always use HEXBINY() together with HEXBINX() for accurate 2D binning.
  • You can use aggregations (SUM, COUNT, AVG) to summarize measures within each hexbin.
  • LOD expressions allow you to compute statistics per hexbin region.
  • Adjust axis scaling to control the visual size of hexagons — Tableau automatically manages bin size based on the plot scale.
  • HEXBINY() only works with numeric fields (not dimensions or strings).
  • Hexagon sizes are dynamic and can vary depending on the data range and view scaling.

Related Functions You Might Need

FunctionPurpose
HEXBINX()Returns the X-coordinate of the hexagonal bin center.
ROUND()Rounds numbers to a specific precision (used for grid-based binning).
INT()Truncates numbers to integers (used for simple square bins).
INDEX()Returns the index of a mark (useful for ordering or sorting bins).
SIZE()Returns the number of marks in a partition (useful for density per hexbin).

We’ve got plenty of resources to help you master Tableau functions. For more details, check out the official Tableau documentation. Or, if you’re ready for more practice, let’s dive into related functions and build your Tableau skills further!

If you’re ready to harness the full power of Tableau and elevate your data analytics capabilities, our expert Tableau consulting services are here to guide you. Whether you need support with building advanced calculated fields, creating dynamic visual dashboards, or optimizing your data sources for peak performance, our team of experienced Tableau consultants delivers customized solutions designed for your business needs. Visit our Tableau Consulting page to discover how we can help your organization turn data into impactful, insight-driven decisions.

1. What does the HEXBINY function do in Tableau?

HEXBINY() returns the Y-coordinate of the center of the hexagonal bin that contains a data point.

2. How is HEXBINY() used with HEXBINX()?

They are used together—HEXBINX() provides the X-coordinate, and HEXBINY() provides the Y-coordinate—to form hexagonal bins on a 2D grid.

3. Can HEXBINY() be used on non-geographic data?

Yes. It can be used on any numeric data, not just geographic coordinates, making it ideal for scatter plots and density maps.

4. Does HEXBINY() automatically determine bin size?

Yes, Tableau automatically adjusts hexbin size based on the data scale and visualization area.

5. Can I aggregate values within each hexbin?

Yes, you can use aggregate functions like SUM(), AVG(), or COUNT() or use LOD expressions to calculate metrics per hexbin.

Established in 2020, Lets Viz Technologies provides a full range of high-quality data analysis and data visualization services. We are also an authorized Zoho Partner.

 

Contact

WeWork Berger Delhi One, C-001/A2, Sector 16B, Noida, Uttar Pradesh 201301

0124-502-5592
info@lets-viz.com

We are Social

Trust Pilot Reviews