3 Replies Latest reply on May 18, 2017 6:03 AM by SANDIP SHARMA

    Help with exporting csv after applying filters on a view in Tableau Server

    Cristina Martinez

      Hello,

       

      I've been struggling with this for a while and I have come to the conclusion that I need help from this community.

       

      I have a dashboard with a few tabs, the first one is a list of activities, if you click one of the activities, an action takes you to the Overview tab(viz), where you will see detailed info about the selected activity, all the subsequent tabs are filtered based on the selected activity. When I save and publish this dashboard, I pre-select an activity to prevent users from accidentally going to the other tabs (All tabs are exposed) and running into performance issues due to the size of the unfiltered date.

       

      I though that if I used the tabcmd export to extract a csv file of my data for a particular activity, the currently selected activity data will be downloaded. What I am getting is data related to the default activity that I selected when I published the dashboard to the server. I have not been able to successfully change those filters programmatically.

       

      I also tried with URL parameters, but it the behavior that I see is that you can further filter your data using the url parameter, but you can't revert a filter already applied and choose a select a new one a new one.

      Example: if your data wookbook is filtered for Category = Table by default, as far as I understand you can't set Caterory= All and then Category = Paper

      http://public.tableausoftware.com/views/QuickFilterByURL_Target/Target?Category=All&Category=Paper

       

      If you understand what my issue is, I will greatly appreciate your help to move in the right direction to be able to export a csv file with data for the activity of my choosing and be able to change the activity. All using a scripting language such as tabcmd.

       

      Many thanks,

      Cristina

        • 1. Re: Help with exporting csv after applying filters on a view in Tableau Server
          Toby Erkson

          If I'm reading correctly (and you've done a really good job explaining , thank you! ) then what you are observing is correct.

           

          What you would need to do is have your script download the CSV multiple times, with each time you download you change the filter parameter.  Or else you download the entire CSV so that it contains ALL of the data.

          • 2. Re: Help with exporting csv after applying filters on a view in Tableau Server
            ankit.ravi

            Hey Cristina, did you manage to get a solution for this, I have a similar issue?

             

            Thanks

            • 3. Re: Help with exporting csv after applying filters on a view in Tableau Server
              SANDIP SHARMA

              Hi Cristina,

               

              If I understood your problem correctly then you want to export your data into CSV by passing filters on the dashboard pragmatically. I did the same for your using Power Shell scripting. Power Shell has capability to loop in your all the filter values which need to be passed in your dashboard one by one.

               

              If your values are not fixed then create a separate dashboard for the values which will we passed as filter in your original dashboard.

              For Example: You have created a sheet of your Employees details by each department. In this case Department will be your key which will be passed in this dashboard to create individual CSV file for each department.

               

               

              Create a separate sheet which will contain only Department details init and publish the same to server. and your original dashboard which contains the info of all the employees for each department and place a filter of Department in it and publish the same to server. now use below script which will help you in generating the CSV files for each department

               

               

              Clear

              $view_url = "RegionDetails/Department"

              $saved_file = "F:\TS Learning\User Creation Alert to User\Department.csv"

              Set-Location "C:\Program Files\Tableau\Tableau Server\10.2\extras\Command Line Utility"

              .\tabcmd.exe login -s your server -t your_site -u user -p password

              .\tabcmd export "$($view_url)?:refresh=yes" --csv  -f "$saved_file"

              .\tabcmd logout

              $csvfile = import-csv -path $saved_file

              $view_url = "/views/RegionDetails/Employee_Dashbaord"

              foreach ($line in $csvfile)

              {

              $view_url = "/views/RegionDetails/Employee_Dashbaord" + ".pdf?Show=Show&Department=$($line.Department)"

              $saved_file = "F:\TS Learning\PDF\$($line.Department).pdf"

              Set-Location "C:\Program Files\Tableau\Tableau Server\10.2\extras\Command Line Utility"

              .\tabcmd.exe login -s your server -t your_site -u user -p password

              .\tabcmd get "$view_url" -f "$saved_file"

              .\tabcmd logout

              }

               

              In my case I created PDF replace the .pdf with .csv.

               

              If you have any problem in above script please feel free to write me.

              3 of 3 people found this helpful