5 Replies Latest reply on Oct 8, 2013 10:29 PM by Aakash Jain

    Synchronization of dashboard's filter and API's filter.

    Sk Safi

      Hi Team,

       

      Can we synchronize the dashboard's filter and the JS's API filter dynamically..?

      Below are the description :

       

      Ex. The dashboard contain Country filter.

             We also have to create the Country filter using HTML .

             Now how can we synchronize those filters..?

       

       

      Please give some light on the above mentioned issue.

       

       

      Thanks,

      Safi

        • 1. Re: Synchronization of dashboard's filter and API's filter.
          Aakash Jain

          Hi Safi,

          We can use filters using JavaScript API on sheet level and not on dashboard level. Also you can hide the filters used in your dashboard and instead use them in your HTML page directly using JavaScript API.

          You have to filter each sheet present in the dashboard individually. You can use this code to select your sheet from the dashboard

          viz.getWorkbook().getActiveSheet().getWorksheets().get("[Sheet Name]");

          Hope it helps

           

          Regards,

          Aakash

          • 2. Re: Synchronization of dashboard's filter and API's filter.
            Sk Safi

            Hi Aakash,

             

            I don't want to control the filter using HTML.

            Actually I want to know how we can populate the html filter with the values present in the dashboard's/sheet's filter dynamically.

             

             

            Thanks,

            Safi

            • 3. Re: Synchronization of dashboard's filter and API's filter.
              Aakash Jain

              Hi SK,

                   Sorry but I don't think we have access to filter values using JavaScript API in tableau server. Still not sure as there might be some workarounds to achieve the same, I haven't found any such yet.

              What I did was I took the values directly from the website database from which tableau server was visualizing and passed those selected values in the url for filter parameter. It worked well for me.

              • 4. Re: Synchronization of dashboard's filter and API's filter.
                Sk Safi

                Hi Aakash,

                 

                I am not able to understand how and what you are doing.

                Can you post your sample code....?

                 

                Thanks,

                Safi

                • 5. Re: Synchronization of dashboard's filter and API's filter.
                  Aakash Jain

                  Hi SK,

                       My tableau viz was created on the data present in the database of which I created a extract and uploaded to server. All the filters my tableau viz will be requiring were present in the same DB. Now when I created a web page using that DB as backend I had access to those filters too. So instead of taking filter values from tableau server instead I took those values from the database itself and listed them in my page and hide those quick filters in my tableau viz. I was using dropdown in my page to select the filter values and on select I was applying the filters to all the sheets in the viz using JavaScript functions.

                  I don't have the exact code with me but i can share you an example of what I did:

                  function filterAttr() {

                   

                   

                      var s1 = viz.getWorkbook().getActiveSheet().getWorksheets().get("Sheet 1");

                      var s2 = viz.getWorkbook().getActiveSheet().getWorksheets().get("Sheet 2");

                      var s9 = viz.getWorkbook().getActiveSheet().getWorksheets().get("Sheet 3");

                     

                      s1.applyFilterAsync("Attr", "Val 1", tableauSoftware.FilterUpdateType.REPLACE);

                      s2.applyFilterAsync("Attr", "Val 2", tableauSoftware.FilterUpdateType.REPLACE);

                      s3.applyFilterAsync("Attr", "Val 3", tableauSoftware.FilterUpdateType.REPLACE);

                       

                  }

                   

                  Regards,

                  Aakash