3 Replies Latest reply on Jun 18, 2018 10:43 AM by Joe Oppelt

    Dynamic URL for CSV Export based on Quick Filters

    Craig G

      I am looking to add an image to a dashboard that will act as an export button. The dashboard will contain a series of graphs. When clicked, it will export the full data in CSV format for one of the graphs including the quick filters the user applied. I have referecned the following articles but am still not getting this to work:

       

      How View URLs Are Structured

       

      The Greatest Tableau Tip EVER: Exporting CSV made simple!

       

      I am not able to successfully pass through the quick filters and have it export to CSV. Also, even when ignoring the filters, it only exports summary data. Any ideas?

       

      The URL format I am using is as follows:

       

      htps://"Standard Dashboard URL"?DimensionName1=<FilterValues(DimensionName1)>&DimensionName2=<FilterValues(DimensionName2)>.csv

        • 1. Re: Dynamic URL for CSV Export based on Quick Filters
          Joe Oppelt

          You want the CSV before the parameter and filter values.

           

          I load my URL into a calc and then use the calc for the hyperlink value.


          Here is one such calc:

           

          "https://(my server here)/#/views/PledgeAnalysis_0/ExcelButtonselections.csv" +

          "?End%20Analysis%20Period="+STR([End Analysis Period]) +

          "&End%20Date="+([End Date]) +

          "&Start%20Date="+[Start Date] +

          "&Start%20Analysis%20Period="+STR([Start Analysis Period]) +

          (etc.)

          • 2. Re: Dynamic URL for CSV Export based on Quick Filters
            Craig G

            Thank you for the tip on where to place the .csv extension.

             

            To pass along the user selection in a quick filter, what is the URL code? For example, if the dimension being filter on is Dimension1, what does the URL look like?

             

            Also, any tips on getting underlying data, and all rows?

            • 3. Re: Dynamic URL for CSV Export based on Quick Filters
              Joe Oppelt

              In the attached (V 10.5 example) I have 2 sheets.  Each sheet is on its own dashboard to keep things straight.

               

              I published the first sheet to Server.  You'll do the same on your server.

               

              The first sheet (on the first dashboard) has a [URL String] calc that builds the string up to the start of passing the [State] filter value.  Look at the hyperlink action on dashboard 1 to see the syntax.  I tried using the FILTERVALUES function here, but I don't like how it works.  Click on a dot.  It activates the hyperlink action.  You get a new browser window opened up.  Notice the URL that gets passed.  It looks like this:

               

              metrics.fotf.org/#/views/Superstore/Sheet2.csv?State=AlabamaArizonaArkansasCaliforniaColoradoConnecticutDelawareDistrict%20of%20ColumbiaFloridaGeorgiaIdahoIllinoisIndianaIowaKansasKentuckyLouisianaMaineMarylandMassachusettsMichiganMinnesotaMississippiMissouriMontanaNebraskaNevadaNew%20HampshireNew%20JerseyNew%20MexicoNew%20YorkNorth%20CarolinaNorth%20DakotaOhioOklahomaOregonPennsylvaniaRhode%20IslandSouth%20CarolinaSouth%20DakotaTennesseeTexasUtahVermontVirginiaWashingtonWest%20VirginiaWisconsinWyoming

               

              Notice that there aren't any commas between the values?  When you click on a dot and activate this hyperlink, Tableau receives this on the server and tries to display ONE state with a value of all those concatenated state names.  (Of course there is no such state, and you get an empty excel sheet.)

               

              Let's look at the second copies of the sheet and dashboard.  On Sheet 2(2) I made my own calc to gather the list of state names.  See URL string2.  It's a table calc that shoves commas in there.  On the display you can see the value growing from state to state as you go down the sheet.  The previous_value function is a cool function that grabs what is in the previous cell and lets you do stuff with it in the current cell.  Here I am adding each next state name.

               

              Then I made one more calc that grabs the largest value of the string (effectively, the last value.)  That's the value I want to pass to the URL.  I shoved the full URL value in the title of this sheet so you can see what is getting passed to Server.  We can still use Sheet2 that we published earlier.  Add states in and take states out to see what's going on with these calcs.  Then click one of the rows and you'll get the excel sheet for Sheet 2.

               

              Something important here.  When you are doing the ".CSV" trick, you are essentially telling tableau to take the published sheet and shove it into excel.  It's not doing underlying data or anything like that.  Whatever you want to see in the excel sheet should be added to the published sheet.