Sorting by time in tableau.

Being able to sort using a date or datetime field in Tableau is a problem I have run into a few times.

The intuitive way you would probably expect for it to work is to right click the dimension you want to sort. Then by field and look for the date field you want to sort by, pick ascending  or descending and jobs done. However, for some reason Tableau does not allow you to do that.

There are two ways that I have thought of so far to deal with these problems. The first is to add the data column you want to sort by as the first column. This has lead to some issues with table calculations. I'm sure these can probably be fixed after a lot of fiddling but there is an easier approach.

Using the DATEDIFF function you can calculate how many seconds, minutes, hours, etc. there have been from a point in time compared to today. Then you can use sort the intuitive way and sort using that field.

Author:
Terrence Miller
Powered by The Information Lab
1st Floor, 25 Watling Street, London, EC4M 9BR
Subscribe
to our Newsletter
Get the lastest news about The Data School and application tips
Subscribe now
© 2025 The Information Lab