In Tableau, I have values by year, but I need values by decade. How do I bin or create a group of years to create that?

182 Views Asked by At

In Tableau, I have values (of NO3) by year, but I need values by decade. How do I bin or create a group of years to create that? Dates data is date plus time if that's relevant.

I feel like I should be able to easily merge the highlighted dates together, but I don't see where I can do that. I've tried doing a calculated field, but I'm not entirely sure how that works.

Tableau screenshot

1

There are 1 best solutions below

1
MUFF. On BEST ANSWER

Two options:

Grouping

Hover your selected fields and click the paperclip looking icon to create a group.

Create Custom Buckets via a Calculated Field

Create a calculated field called [Decades] and using an if statement conditionally segment your data. How this would look right now with your current data:

IF YEAR([Date Smp]) >= 1990 AND YEAR([Date Smp]) <= 1999 THEN '90s'
ELSEIF YEAR([Date Smp]) >= 2000 AND YEAR([Date Smp]) <= 2010 THEN '2000s'
ELSEIF ...
END

EDIT An easier variation of this approach is to create a calculated field called Year defined as YEAR([Date Amp]) Then right click on that new field in the data pane (left margin) and Create a Histogram bin field with a bin size of 10. Name it Decade.

Decade will display as the first year of a decade, which might not be as readable but is simple.

Another variation to get more readable decade values - instead of letting Tableau automatically create the bin field, make it yourself with some simple math such as STR(YEAR([Date Amp]) / 10 * 10) + "'s" That way you don't have to hard code decade boundaries and your code will work forever :-)

Drag [Decades] out to your columns shelf.