Tableau - Date Truncation

Return the first day of the week, month, quarter or year using DATETRUNC

                    DATETRUNC(date_part, date, [start_of_week])

The date_part can be:

  • day
  • week
  • month
  • quarter
  • year

[start_of_week] is an optional parameter which can be any day of the week (i.e "Monday", "Tuesday", etc)


Return the first day of this year

                    DATETRUNC('year', TODAY())

Return the first day of the quarter

                    DATETRUNC('quarter', TODAY())

Return the first day of the month one year ago

                    DATETRUNC('month', TODAY() -365)

Some tips:

  • Convert to an exact date
  • Change data type to discrete

These calculations come in handy when finding the number of days in the month, quarter or year dynamically.

  • SEO
  • Online Advertising
  • Online Ordering For Restaurants
  • Data Analytics

  • External Resources 4 Developers
  • CSS Tricks
  • MDN

  • is a Power BI and Tableau resource site around data visualizations and building business dashboards.

    Data Analytics consultants in Edmonton, Alberta specializing in Tableau and marketing analytics

    Copyright 2020 Terms / All rights reserved.