MIP Logo

How to create a Custom dates in Tableau?

This post was originally published on The Data School blog between 2018 and July 2025, before our program was renamed to MIP’s Analytics Career Accelerator. References throughout this article to “The Data School” or “DS” all refer to what is now MIP’s Analytics Career Accelerator. The program, its people, and its commitment to launching outstanding analytics careers remain the same – just under a new name.

If you are having trouble viewing this article, please report it here. 

In this blog, I will take through how to create custom dates for yearly, monthly, quarterly, Weekly, Daily, Last month, Last week Yesterday.

 

 

Step 1 – Create Parameters for Date Range:

Create a parameter with a data type of string and create list for the above dates. Once these are created, right-click on each one and choose “Show Parameter Control”.

 

 

 

 

 

 

 

 

 

Step 2 – Create Calculated field:

  • Create a calculated field that uses Datename() function. The Datename() function returns a part of the given date as a string part  and let us  name that calculated field as Date.

 

 

 

 

 

 

  • To compute “last month”,” Yesterday”& “Last week” .First of all, we need to find the latest date . This can be achieved by the following calculation:

 

 

 

 

 

 

 

  • Now we can use date diff of month for the max-date and order date to find the difference between the two dates.If it returns a value of 0 then return the latest month date.

 

 

 

 

 

  • Similarly, we can create calculated fields for Yesterday , Last week as above calculation by replacing “week” and “days” in the datediff function

 

Step 2 – Create view:

Drag the Date and Segment field from dimension and place Date in columns and Segment in rows and sales in rows.

 

 

 

 

 

 

 

Share this post