Tableau - Filter/Parameter For Different Date Ranges

六眼飞鱼酱① 提交于 2019-11-28 09:48:54

问题


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?

Edit: I should have been more clear here.

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


回答1:


Update

Based on your comment and updated question, you can do it as you intend, though it isn't as straight-forward.

NOTE: I did this very quickly and with a random data set, so it will be important for you to test this thoroughly with your data set.

Steps:

  1. 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):

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

Calculation: INT([Date Filter Parameter]) > DATEDIFF("week",ATTR([Date Field]),WINDOW_MAX(MAX([Date Field])))

  1. Place the calculated field in the filter box and set it to True.

You will be able to filter your data like so:


Original Answer

Yup - that is built into Tableau.

Add your date to the filter and select the "Relative Date" option:

You can set the defaults - users can change these later:

Then just "Show Filter":



来源:https://stackoverflow.com/questions/37951031/tableau-filter-parameter-for-different-date-ranges

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!