This should work:
This is essentially passing a date value using Tableau's internal date format and URL encoding, i.e. space is %20 and : (colon in time part) is %3A.
If your date field does not have time component, then you can just pass date only, i.e. 2013-01-29.
1 of 1 people found this helpful
I just wanted to follow up in case anyone runs into this thread.
What I was trying to accomplish with my original question was to approximate a "relative" date filter in the URL. I love relative date filters. I include them in a lot of my views because its easy to identify "Last Month", "Last Week", "This Week", etc. But sometimes I just want my users to enter a date and have it return the "Last Month" from that user defined date. Here's how I accomplished that... sort of.
- First, you'll need to determine your date "window". For this example lets use 30 days.
- Create a parameter with a unique name. Here we'll use "AdjDate".
- Set the parameter to "Date", set the current value to "Today", set display format to automatic, and set allowable values to "All".
- Next, create a calculated field that will return True/False. It doesn't need a specific name, just something you'll remember. I'm going to use "Calculation1".
- Inside "Calculation1" copy/paste this code.
- DATEDIFF('day',[Date],[AdjDate]) <= 30
- "[Date]" is obviously your date field for comparison.
- DATEDIFF('day',[Date],[AdjDate]) <= 30
- Next, create another calculated field that will return True/False. I'm calling this one "Calculation2"... Brilliant!
- Inside "Calculation2" copy/paste this code.
- DATEDIFF('day',[Date],[AdjDate]) >= 0
- Now the fun!
- Drag "Calculation1" to the filters shelf and click "True". Click the box!
- Drag "Calculation2" to the filters shelf and click "True".
- Right click on the "AdjDate" parameter and click Show Parameter Control.
- Now drag whatever measure values you want onto the sheet and change the AdjDate parameter to get the last 30 days from the date you chose.
Pretty cool right? Now, if you're running Tableau Server and publishing this view you can also use the AdjDate parameter in the URL!
I have struggled with the same issue for the last three days and finally came up with my own solution that I wanted to post here as an alternative option to yourself and other users.
- - Tableau requires dates to be passed in the following format: “yyyy-mm-dd”.
- - Because we are working with date ranges, we have the issue of getting all the dates in the range to export.
- - There is no >= or <= operators available when passing filter values via a URL
How I got around this: My solution was to pass filter values to the “Date Month” field in the URL. This way, all dates that fall within a date month for which we are filtering will be exported. My main problem was that the user is not selecting individual months, instead the user is selecting a range of dates defined by a parameter. So the user selects values like “Last 3 months”, “Last month”, etc. So, in my end solution, my url string looks something like this: http://tableauserver/...../WorkbookDash.csv?DateMonth=<FILTERVALUES(Calc2)> which when I click on it resolves to something like this: http://tableauserver/...../WorkbookDash.csv?DateMonth=2013-01-01,2013-02-01,2013-03-01 My solution is as follows:
- - Create a new calculated field (lets call this Calc1) that derives the date values to select based off of the time frame selected by the user
- - Create another calculated field (lets call this Calc2) that is a varchar field that constructs the month/year of Calc1 in the format of yyyy-mm-dd, where “dd” is always “01”. The key here is this MUST resolve to a string so the default Tableau date formatting doesn’t override our format when we use this as a filter.
- - Drag Calc2 onto the filter pane and select “Show filter”. Now you will see all of the date month strings that are available in the database. Make sure this filter values are showing as a multi-select list.
- - Here is the KEY step that makes this work: Make sure you click on the filter control for Calc2 and select “Only Relevant Values”. This will ensure that only the months that correspond to the date range the user has selected appear in the filter drop down.
- - Place the new filter on the dashboard where the URL action will be located. If you don’t want to show this filter for aesthetic purposes, you can add a floating container on top of it to hide it from the users view.
- - Publish and test your workbook! This should work like a charm.
NOTES: For a while, I was using the “Test Link” option in the Dashboard Actions UI within Desktop to test out my solution. Plese note that this link will ONLY ever show you the first three values of the data you are selecting. I didn’t see any place where this was documented and I wasted a whole lot of time thinking my solution wasn’t working before I figured this out.
I hope this helps anyone who has struggled with allowing a user to export data based on a date range.
Sarah, seems you have understood how values are passed through URLs.
I am stuck and unable to do that.
Can you help me with my following question please.
Much appreciated in advance.