01 / 20

Clustering in
Tableau

Learn how clustering algorithms automatically group data points into meaningful segments, and how to interpret those segments to unlock insights in your visualizations.

Tableau

What Is Clustering?

Clustering is an unsupervised machine learning technique that groups data points so that points within a group are more similar to each other than to those in other groups. Unlike classification, there are no predefined labels: the algorithm discovers the structure on its own.

Why Clustering Matters

Discover Patterns
Reveal hidden customer segments, product groupings, or regional trends you might miss manually.
Data-Driven Decisions
Target marketing campaigns, optimize inventory, and allocate resources based on segment behavior.
Built Into Tableau
Tableau provides one-click clustering with drag-and-drop simplicity: no coding required.

Visualizing Clusters in a Scatter Plot

Revenue per Customer Purchase Frequency Cluster 1 Cluster 2 Cluster 3

The K-Means Algorithm

Tableau uses k-means clustering under the hood. The algorithm minimizes the total within-cluster distance: the sum of squared distances from each point to its cluster's centroid.

1
Initialize: Choose \( k \) starting centroids (randomly or via heuristic).
2
Assign: Each point joins the cluster with the nearest centroid.
3
Update: Recalculate each centroid as the mean of its members.
4
Repeat steps 2-3 until centroids stabilize (convergence).

K-Means: Iteration by Iteration

Step 1: Init Random centroids placed Step 2: Assign Points join nearest centroid Step 3: Converge Centroids stabilize Tableau performs this automatically when you add clusters to a view.

Clustering vs. Classification

Clustering Classification
Learning Type Unsupervised Supervised
Labels No predefined labels Requires labeled training data
Goal Discover groups Predict known categories
Output Cluster assignments (1, 2, 3 ...) Predicted class (e.g., "Spam")
Tableau Feature Analytics pane: Cluster Not built-in (use TabPy)

How to Apply Clustering in Tableau

1
Build a scatter plot: Place two continuous measures on Columns and Rows (e.g., Sales vs. Profit).
2
Open the Analytics pane: Click the Analytics tab (next to the Data tab on the left).
3
Drag "Cluster" onto the view: Tableau automatically determines the optimal \( k \) or you can set it manually.
4
Inspect the clusters: Click any cluster's color legend to see which data points belong to it.
5
Interpret and name: Describe what each cluster represents conceptually (e.g., "High-Value Loyalists").

Choosing the Number of Clusters (\( k \))

Tableau can auto-select \( k \), but understanding how it decides helps you override wisely. A common heuristic is the elbow method: plot the within-cluster variance against \( k \), and look for the "elbow" where adding more clusters gives diminishing returns.

Number of Clusters (k) Within-Cluster Variance 1 2 3 4 5 Elbow

Example 1: Customer Segmentation

A retail company plots Average Order Value (x-axis) vs. Number of Orders per Year (y-axis) for 500 customers. After clustering with \( k = 3 \):

Cluster 1
Low order value, low frequency: "Casual Browsers". They need engagement campaigns.
Cluster 2
Moderate value, high frequency: "Loyal Regulars". Reward with loyalty programs.
Cluster 3
High value, moderate frequency: "Big Spenders". Offer premium experiences.

Example 2: Sales and Profit Analysis

Sales ($) Profit ($) $0 Stars Steady Drains

Reading Tableau's Cluster Summary

When you right-click a cluster in Tableau and select "Describe Clusters", you get a summary table. Here is how to interpret the key metrics:

Metric Cluster 1 Cluster 2 Cluster 3
Count 210 180 110
Avg Sales $45 $320 $780
Avg Profit -$12 $85 $210

Using Clusters as a Dimension

Once Tableau assigns clusters, the result appears as a new dimension on the Marks card. You can then:

1
Color by cluster: Drag the Clusters pill to Color to distinguish segments visually.
2
Filter by cluster: Show only one cluster to drill into its characteristics.
3
Save as a group: Right-click the Clusters pill and select "Save as Group" to create a reusable field.
4
Cross-reference: Place Cluster on Rows and another dimension on Columns to see segment composition.

What Inputs Does Tableau Use?

Tableau clusters on the measures currently in the view. This means the variables on your Rows, Columns, and Marks card determine the clusters.

Measures Only
K-means requires numeric, continuous variables. Dimensions are not used by the algorithm directly.
Scaling Matters
Tableau standardizes (z-scores) each measure before clustering so that scale differences do not dominate.

Common Mistakes

✕ Ignoring Outliers
Outliers pull centroids, creating misleading clusters. Filter extreme values before clustering.
✕ Wrong \( k \) Value
Choosing too many clusters creates noise; too few hides real patterns. Use the elbow method or domain knowledge.
✕ Treating Clusters as Causal
Clusters show correlation, not causation. "Cluster 2 has high profit" does not mean cluster membership causes profit.

Clustering Summary

Concept Details
Algorithm K-means (unsupervised)
Input Continuous measures in the view
Choosing \( k \) Auto or manual; use elbow method
Output Cluster dimension (1, 2, 3 ...)
Key Metric Within-cluster variance (lower = tighter)
Interpretation Name clusters by meaning, not number
Limitation Sensitive to outliers and measure selection

Question 1 of 5

Clustering in Tableau is an example of which type of learning?

Question 2 of 5

In the k-means algorithm, what does the "centroid" represent?

Question 3 of 5

A scatter plot shows three distinct groups of customers. You apply clustering and Tableau assigns \( k = 3 \). One cluster has high average order value and low frequency. What is the best label for this segment?

Question 4 of 5

Why does Tableau standardize measures before running k-means?

Question 5 of 5

In the elbow method for choosing \( k \), you should select the value of \( k \) where: