Tableau Function Categories
Tableau : Number Functions
Tableau Function: HEXBINX
Category: Number Functions
The HEXBINX() function in Tableau is a spatial binning function that computes the X-coordinate of a hexagonal bin in a hexbin plot.
It is typically used alongside the HEXBINY() function to create hexagonal binning visualizations, which group data points into hexagonal cells based on their spatial distribution.
Purpose
The main purpose of HEXBINX() is to aggregate and visualize large volumes of spatial data efficiently.
When you have thousands or millions of data points (e.g., geographic coordinates or scatter plot points), plotting them individually can cause clutter.HEXBINX() helps reduce this clutter by grouping nearby points into hexagonal bins—each representing a region or cluster of data points.
Type of Calculation
Geospatial / Numeric Aggregation Function
Performs coordinate-based transformation from raw numeric (X) values to hexbin grid coordinates.
Practical Use Cases
Density Plots: Visualize data point density in scatter plots.
Geographic Analysis: Aggregate spatial data (e.g., longitude/latitude) into grid cells.
Outlier Detection: Identify high-density and low-density regions visually.
Performance Optimization: Summarize large datasets into manageable hexagonal regions.
Heatmaps: Combine
HEXBINX()andHEXBINY()with color or size to represent data intensity.
HEXBINX(expression)
| Parameter | Type | Description |
|---|---|---|
expression | Numeric (usually a column or calculation) | Represents the X-coordinate value of a data point. Typically a field like [Longitude], [X Position], or a numeric axis value. |
How It Works?
The HEXBINX() function divides a two-dimensional space into hexagonal bins (like a honeycomb grid).
Each hexagon covers a specific area of your data’s coordinate plane.
For each data point, Tableau determines which hexagon it belongs to, and HEXBINX() returns the X-coordinate of that hexagon’s center.
Mathematically, Tableau internally maps the coordinate system into a hexagonal tessellation, using a predefined hexagon size determined by the data range and view scale.
Each hexagon has:
A center X → computed by
HEXBINX()A center Y → computed by
HEXBINY()
These coordinates are then used to group data points into bins for aggregation.
Formula Conceptually (Simplified):
HEXBINX(x) = ecenter of the hexagonal bin containing x
What Does It Return?
Type: Floating-point number (decimal)
Meaning: The X-coordinate of the hexbin center corresponding to the input data point.
Used with:
HEXBINY()to get the corresponding Y-coordinate.
When Should We Use It?
Use HEXBINX() when you want to:
Simplify dense scatter plots or maps using hexagonal bins.
Visualize spatial distributions or density of data points.
Create aggregated heatmaps with fewer marks.
Perform spatial aggregation without manually calculating grid boundaries.
Combine with color, size, or opacity to represent counts or averages per bin.
Basic Usage
HEXBINX([X])
Description: Returns the X-coordinate of the hexbin that contains the data point [X].
Example:
| X Value | HEXBINX(X) |
|---|---|
| 2.3 | 2.5 |
| 2.7 | 2.5 |
| 3.1 | 3.0 |
Here, multiple nearby X-values may fall into the same hexbin (e.g., 2.3 and 2.7 both map to 2.5).
Column Usage (Scatter Plot Binning)
When plotting a scatter plot:
HEXBINX([Longitude])
HEXBINY([Latitude])
Use these as calculated fields for your X and Y axes.
Then use a COUNT() or SUM() aggregation (like COUNTD([ID])) to color or size the bins by the number of points.
This helps create a hexbin density plot showing data concentration.
Advanced Usage – Combined with Aggregation
You can calculate the average sales per hexbin region:
{ FIXED HEXBINX([X]), HEXBINY([Y]) : AVG([Sales]) }
This level of detail (LOD) expression groups your data by hexagonal bin and computes the average sales in each.
Tips and Tricks
- Combine with
HEXBINY()— Both functions are used together to create a complete hexbin visualization. - Add aggregation — Use
COUNT(),SUM(), or LOD expressions to summarize metrics per bin. - Use calculated fields — Create
Hexbin XandHexbin Yfields for flexible plotting. - Adjust bin size — Tableau automatically scales hexagon size based on your visualization, but you can adjust by zooming or changing axis ranges.
- Coordinate inputs must be numeric. Using dimensions like strings or categories will cause errors.
- Do not confuse with geographic longitude/latitude projection errors — ensure consistent coordinate units.
Related Functions You Might Need
| Function | Purpose |
|---|---|
HEXBINY() | Returns the Y-coordinate of the hexbin center corresponding to a data point. |
ROUND() | Rounds a numeric value to a specific precision (useful for grid-based grouping). |
INT() | Truncates a value to an integer; can be used for square grid binning. |
INDEX() | Returns the position of a mark; not spatial but useful in sorting hexbin results. |
SIZE() | Counts the number of marks in a partition — useful for density calculation. |
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.
HEXBINX() returns the X-coordinate of the center of a hexagonal bin containing a data point.
They are used together — HEXBINX() for the X-coordinate and HEXBINY() for the Y-coordinate — to create hexagonal binning visualizations.
Yes, any numeric data can be used. It doesn’t require geographic data — works for any scatter plot or coordinate system.
HEXBINX() maps data into hexagonal regions, while ROUND() simply rounds numbers to decimal precision — no spatial logic involved.
Yes. By aggregating data points into bins, it reduces clutter and improves rendering speed on dense visualizations.
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
