Last Modified Date: 18 Aug 2020
Environment
- Tableau Desktop
- Tableau Server
- Linking views using URL actions
Answer
- Create two parameters to work as date range filters:
- The "Amount" - how many units of the date part do we want relative to Today? (Or anchor date)
- Create a parameter that has an integer format, and allows all values.
- The "Date Part" - which date part to use relative to Today? (Days, weeks, months, etc.)
- Create a parameter that has a string format, and allows a list of values.
- Populate the list with the dateparts you want to be able to use for the relative date filter, ex: "Days", "Weeks", "Months", "Years"
- The "Amount" - how many units of the date part do we want relative to Today? (Or anchor date)
- Create a calculated field to use as a filter for the parameter controls:
IF [Date Part]="Days" THEN
(IF DATEDIFF('day',[Date Field],TODAY())<=[Amount] THEN "Show" ELSE "Hide" END)
ELSEIF [Date Part]="Weeks" THEN
(IF DATEDIFF('week',[Date Field],TODAY())<=[Amount] THEN "Show" ELSE "Hide" END)
ELSEIF [Date Part]="Months" THEN
(IF DATEDIFF('month',[Date Field],TODAY())<=[Amount] THEN "Show" ELSE "Hide" END)
ELSEIF [Date Part]="Years" THEN
(IF DATEDIFF('year',[Date Field],TODAY())<=[Amount] THEN "Show" ELSE "Hide" END)
END
- Drag the calculated field onto the "Filters" shelf, and select "Show" to keep.
- Create calculated fields to use as URL controls:
- [Amount URL]
"Amount="+STR([Amount])+"&"
- [Date Part URL]
"Date%20Part="+[Date Part]
- [Amount URL]
- Make sure the URL control calculated fields are on the Details shelf in the view(s) that are the target of the URL action(s).
- Create the URL action(s) with the following format for the URL:
<worksheet URL>?<Amount URL><Date Part URL>
Additional Information
Discuss this article... Feedback Forum
Thank you for providing your feedback on the effectiveness of the article.
Open new Case
Continue Searching
Knowledge Base
Community
Product Help
Training and Tutorials