forums

Use these forums to ask questions and discuss Tableau.

Creating ad-hoc groups on date levels?

Is there any way to create ad-hoc groups on date levels? My data is stored at the dd/mm/yy level but I am displaying at the year level (I love the levels feature-no longer have to parse out dates in the source data!). I would like to be able to create custom groups for these years (i.e. 1990-1999, 2000-2008) but I can only create groups on the dd/mm/yy level. Thanks.

Comments

It's easiest do do this sort of grouping on dates as a calculated field. It will be faster than a group, too.

For a simple decade you could do the calculation

Decade
INT(Year([Date]) / 10) * 10

If you'd rather make it clear that you meant the whole decade you could do a string calc:

DecadeString
STR([Decade]) + '-9'

For more arbitrary boundaries you can use IF in your calculation:

YearGroup
IF Year([Date]) < 1990
THEN 'Old'
ELSEIF Year([Date]) < 2000
THEN 'Nineties'
ELSEIF Year([Date]) < Year(Now())
THEN 'Recent'
ELSE 'This Year'
END

Thanks, I'll give this a shot!

If you are still wondering about this, there is also an article in the Tips & Tricks that explains how to create custom date levels using a calculated field and bins. You can read more here.