4 Replies Latest reply on Dec 2, 2017 2:32 PM by parvinder.bindra.0

    URL Date Filtering?

      Is it possible to use the date, specifically an anchor date, in a url filter on Server?

       

      I'm referring to this article: http://kb.tableausoftware.com/articles/knowledgebase/view-filters-url

       

      So instead of using ... /SalesPerformance?Market=West

       

      Could I use... /SalesPerformance?Date=??? , where ??? is in either mm/dd/yyyy format or "today", "yesterday", "last 3 weeks", etc.

       

      I'm just not aware of the proper syntax. Any help would be greatly appreciated.

        • 1. Re: URL Date Filtering?
          Dimitri.B

          This should work:

           

          http://servername/views/workbookname/sheetname?DateFieldName=2013-01-29%2000%3A00%3A00

           

          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.

          • 2. Re: URL Date Filtering?

            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.
            • 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!

            1 of 1 people found this helpful
            • 3. Re: URL Date Filtering?
              Sarah Rowe

              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.

               

              Important points:

              • - 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

              • 4. Re: URL Date Filtering?
                parvinder.bindra.0

                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.

                 

                Passing values using URL from one workbook1 to workbook2

                 

                Much appreciated in advance.

                 

                Thanks,

                Parvinder