Tableau Function Categories
Tableau : Number Functions
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)
| Parameter | Type | Description |
|---|---|---|
expression | Numeric (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 Value | HEXBINY(Y) |
|---|---|
| 2.4 | 2.3 |
| 2.6 | 2.3 |
| 3.1 | 3.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 withHEXBINX()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
| Function | Purpose |
|---|---|
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.
HEXBINY() returns the Y-coordinate of the center of the hexagonal bin that contains a data point.
They are used together—HEXBINX() provides the X-coordinate, and HEXBINY() provides the Y-coordinate—to form hexagonal bins on a 2D grid.
Yes. It can be used on any numeric data, not just geographic coordinates, making it ideal for scatter plots and density maps.
Yes, Tableau automatically adjusts hexbin size based on the data scale and visualization area.
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.
Sitelinks
