• Skip to primary navigation
  • Skip to main content
Antichaos

Antichaos

Tableau, Data Analyse & Visualisatie

  • Home
  • Consultancy
  • Training
  • Blog
  • About Me
  • Newletter
  • Contact
  • Show Search
Hide Search

Year-to-date in Tableau

Johan de Groot · 11 October 2020 ·

If you want to compare last year to this year ‘to date’, you have to take into account that a leap-year adds 1 extra date to the year – so you can’t just compare the day-of-year from this and last year.

Often this filter is used:

DATEPART('dayofyear',[Date]) <= DATEPART('dayofyear',TODAY())

But this is a better one, since this compares day and month:

YEAR([Date]) >= YEAR(TODAY())-1
AND (MONTH([Date]) < MONTH(TODAY())
OR
(MONTH([Date]) == MONTH(TODAY())
AND DAY([Date]) <= DAY(TODAY())))

If you want to have a ‘year to date’ until today (so today excluded), use this one:

YEAR([Date]) >= YEAR(TODAY()-1)-1
AND (MONTH([Date]) < MONTH(TODAY()-1)
OR
(MONTH([Date]) == MONTH(TODAY()-1)
AND DAY([Date]) <= DAY(TODAY()-1)))

Related posts:

Default ThumbnailISO weeks in Tableau Default ThumbnailCalculate last day of month Use Python as an Alteryx connector Top 2000 — 2018

blog, blog-nl

Need help?

Contact me if you need Tableau help on development, implementation or training!
contact@antichaos.net

The Antichaos Update

Like what you’re seeing? Let’s stay in touch!

(The Antichaos update is a short, infrequent newsletter on data, Tableau, usability and more!)

Follow me on LinkedIn

Follow me (and connect!) on LinkedIn to stay up-to-date. Connect on LinkedIn

Antichaos

Copyright © 2025