Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in BI by (17.6k points)

I am trying to set up a filter or parameter for different date ranges in Tableau, such as:

  1. Previous Week
  2. Previous 4-Weeks
  3. Previous 8-Weeks

based on the most recent data in the database. Is this possible?

Is it possible to only have these options in the filter and have it based on the maximum date in the database?

1 Answer

0 votes
by (47.2k points)
  • You need to create a parameter control that the users will use to change the selected date range. I created this as a list of strings with values that I can use directly in a calculated (after simple casting):

enter image description here

  • You have to create a calculated field that you will use as a filter that references the selection of the parameter control. Between the maximum date in the view and the date of any given row is less than the value of the parameter, It tests to see if the difference (in weeks).

enter image description here

  • Calculation: INT([Date Filter Parameter]) > DATEDIFF("week",ATTR([Date Field]),WINDOW_MAX(MAX([Date Field])))
  • Now, Place the calculated field in the filter box and set it to True.

You will be able to filter your data like so:

enter image description here

enter image description here

enter image description here

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...