How to Create Age Bins in Tableau
Grouping individual ages into clean, understandable "bins" or "buckets" like "18-24" or "35-44" is one of the most common tasks in customer data analysis. This quick guide will walk you through three different methods for creating age bins in Tableau, from the super-simple to the ultra-flexible.
Why Bother Creating Age Bins?
Before we jump into the "how," let's quickly touch on the "why." Grouping ages makes your data easier to read, analyze, and visualize. Instead of a messy chart with 70 different bars for every individual age, you get a clean chart with 5-7 meaningful groups. This allows you to quickly spot trends and understand your customer demographics at a glance.
You might be trying to answer questions like:
- Which age group provides the most revenue?
- How does user engagement differ between Millennials and Gen X?
- Are our latest marketing campaigns resonating with a younger audience?
Binned data makes finding these answers much simpler. You can analyze behaviors by generation, lifecycle stage, or any other custom grouping that makes sense for your business.
First, Make Sure You Have an "Age" Field
To create age bins, you first need a field in your dataset that represents a person's age. If you already have a column in your data simply labeled "Age," you're all set and can skip to the next section.
However, it's very common to only have a "Date of Birth" field. If that's the case, you need to create a calculated field to figure out the current age. It's easy to do!
- From the top menu in Tableau, click Analysis > Create Calculated Field...
- Name the field something obvious, like "Age".
- Enter the following formula into the calculation box:
DATEDIFF('year', [Date of Birth], TODAY())Free PDF · the crash course
AI Agents for Marketing Crash Course
Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.
Breaking Down the Formula:
- DATEDIFF: This is Tableau’s function for calculating the difference between two dates.
- 'year': This tells the function you want the difference to be expressed in years.
- [Date of Birth]: This is your date of birth field from your data source. Make sure the field name inside the brackets matches your actual field name exactly.
- TODAY(): This function returns the current date, ensuring your age calculation is always up-to-date.
Click "OK," and you'll now have a new "Age" measure in your Data pane. You can right-click this field and select "Convert to Dimension" if you plan to use it primarily for grouping and labeling.
Method 1: Tableau's Built-in Bins Feature (The Quick Way)
Tableau has a handy feature for quickly creating bins of a consistent, equal size. This is perfect for when you need a fast and straightforward way to group numbers, like creating age bins in increments of 10 years (10-19, 20-29, etc.).
Step-by-Step Instructions
- Find your "Age" field in the Data pane on the left side of your screen.
- Right-click on the "Age" field.
- In the context menu, go to Create > Bins...
- A dialog box will pop up. Here, you can define your bins.
- Tableau suggests a name like "Age (bin)," which you can keep or change.
- The most important setting is the "Size of bins." Enter the numerical width you want for each group. For example, if you enter 10, Tableau will group your ages into 0-9, 10-19, 20-29, and so on.
- Click "OK."
That's it! A new dimension called "Age (bin)" will appear in your Data pane. You can now drag this field into your worksheets to see your data aggregated by these new age groups.
- Pros: This method is incredibly fast and takes just a few clicks. It's great for quick, exploratory analysis.
- Cons: It's not very flexible. You can't create custom ranges that marketers often prefer, like 18-24, 25-34, or 65+. All bins must be the same size.
Method 2: Using Calculated Fields (The Flexible Way)
For full control over your age groups, a calculated field using an <code>IF</code> statement is the best approach. This allows you to define completely custom bins with uneven sizes, which is exactly what most business analyses require.
Step-by-Step Instructions
- Go to the top menu and select Analysis > Create Calculated Field...
- Name your new field something descriptive, like "Age Group."
- In the calculation box, you'll write a series of
<code>IF/ELSEIF</code>statements to define each bucket. Here is a common example:
IF [Age] < 18 THEN 'Under 18'
ELSEIF [Age] >= 18 AND [Age] <= 24 THEN '18-24'
ELSEIF [Age] >= 25 AND [Age] <= 34 THEN '25-34'
ELSEIF [Age] >= 35 AND [Age] <= 44 THEN '35-44'
ELSEIF [Age] >= 45 AND [Age] <= 54 THEN '45-54'
ELSEIF [Age] >= 55 AND [Age] <= 64 THEN '55-64'
ELSE '65+'
ENDBreaking Down the Formula:
- The formula checks each person's age row by row.
- It starts with the first condition (
IF [Age] < 18). If an age is 17, it gets labeled 'Under 18', and Tableau moves to the next row. - If not, it moves to the next condition (
ELSEIF [Age] >= 18 AND [Age] <= 24). If an age is, say, 22, it falls into this category and gets labeled as '18-24'. - This continues down the list until a condition is met.
- The final
ELSE '65+'acts as a catch-all for any age that didn't meet the previous conditions. - The
ENDstatement is required to close the calculation.
Feel free to copy and paste this formula, adjusting the ranges and labels to fit your specific needs. Once you click "OK," your new "Age Group" dimension is ready to use.
- Pros: Offers complete flexibility to create any grouping imaginable. It's robust and automatically applies to any new data that enters your data source.
- Cons: A bit more involved than clicking a button. You have to write a small bit of logical code, which can be intimidating for absolute beginners.
Method 3: Creating Groups Manually (The Visual Way)
If you prefer a more hands-on, visual approach and don't want to write formulas, you can create groups directly from your view. This method is great for one-off analyses or when you're still figuring out which groupings make the most sense.
Free PDF · the crash course
AI Agents for Marketing Crash Course
Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.
Step-by-Step Instructions
- To start, create a simple list of all the individual ages in your data. Drag your Age dimension to the "Rows" shelf. You should see a vertical list of numbers.
- Now, select the ages you want to lump together. For example, hold down the
Ctrlkey (orCmdon a Mac) and click on the numbers 18, 19, 20, 21, 22, 23, and 24 in your list. - With those ages highlighted, hover over your selection, right-click, and select Group. (Alternatively, you can just click the small paperclip icon that appears on the tooltip).
- Tableau will immediately combine those numbers into a single row and create a new field in your Data pane called "Age (group)."
- To rename the default label, simply right-click on the new combined row in your view (e.g., "18, 19, 20...") and select Edit Alias.... You can change it to "18-24".
- Repeat this process for your other groups (e.g., select 25 through 34, group them, and rename the alias to "25-34").
Eventually, you'll have all your individual ages condensed into your desired groups directly in your view, no formulas required!
- Pros: Very intuitive and visual. Requires no formula writing.
- Cons: Can be tedious if you have a wide variety of ages. Most importantly, it's not dynamic. If new data with a new age is added to your dataset, it won't be part of any group and will show up under an "Other" category. The Calculated Field method is better for dashboards that update over time.
**Pro Tip:** Once you create your "Age Group" dimension (using any of the methods), you can drag it onto the Columns shelf and a measure like sales or user count onto the Rows shelf to instantly create a bar chart comparing performance across age groups.
Final Thoughts
Transforming a long list of individual ages into clean, orderly bins is a fundamental step in making your data tell a clear story. Tableau offers several ways to get this done, whether you prefer the speed of automatic bins, the complete control of a calculated field, or the visual simplicity of manual grouping.
As you get more comfortable with analysis, you'll find that having to learn functions, manage calculated fields, and update groups across different reporting tools can be time-consuming. We built Graphed to remove that friction completely. Instead of building bins manually, you can simply connect your data sources and ask questions in plain English, like "show current customer count by age group, with groups for 18-24, 25-39, and 40+" to instantly get a real-time visualization. With tools like Graphed, you can go from raw data to rich insights in a matter of seconds, no setup required.
Related Articles
How to Create Facebook Ads API for Claude Code
Create a Meta Marketing API access token that never expires, using a system user, so Claude Code can pull Facebook ad reports and manage campaigns.
ClickHouse vs Postgres: When to Switch to Columnar
Comparing ClickHouse vs PostgreSQL means matching storage architecture to workload. Row storage wins for transactions. Columnar wins for scan-heavy analytics.
Google Ads for Orthodontists: Get More Booked Consults
Most orthodontic Google Ads campaigns waste money on low-intent searches. The problem is structure, not the platform.