KNOWLEDGE BASE

How to calculate week number relate to reference date


Published: 02 Aug 2022
Last Modified Date: 02 Aug 2022

Question

How to calculate the week number relate to reference date

For example:
Set reference date as 2022-06-01
Expected result:
2022-06-01~2022-06-04: week 1
2022-06-05~2022-06-11: week 2
2022-06-13~2022-06-18: week 3

Environment

  • Tableau Desktop

Answer

Create the following calculation:

INT(
(DATEDIFF('day',[reference date],[Date])-
DATEPART('weekday',[reference date]))
/7+1)+1

User-added image
Did this article resolve the issue?