2 Replies Latest reply on Sep 28, 2018 12:54 PM by Relevant

    Tableau API to select filter values based on user login-in

    Relevant

      Can someone help me figure out how to pass a value to a filter using tableau API. the value cannot be 'ALL' ( so can't do "Region":"")but can be the first one on the list or can even random.

       

      e.g Set a value for Region in the script below:

       

      var viz

      window.onload= function() {

      // When the webpage has loaded, load the viz

          var containerDiv = document.getElementById("vizContainer");

                      url = "https://online.tableau.example",

                      options = {

          "Region":''select a random value here OR first on the list of values"

      width:'1300px',

      height:'835px',

      hideTabs:true,

              hideToolbar:true,

                          onFirstInteractive: function () {

                              console.log("Run this code when the viz has finished loading.");

                          }

                      };

       

       

        viz = new tableau.Viz(containerDiv, url, options);

      };

       

      Thanks you

        • 1. Re: Tableau API to select filter values based on user login-in
          Santiago Sanchez
          • Something like this works, also see attached:

           

          // just change the url variable to make this work.

          var url = "https://public.tableau.com/views/csvexport/Dashboard1";

           

          // Initialise the viz to hold the workbook

          function initializeViz(){

              var placeholderDiv = document.getElementById("tableauViz");

              

              var options = {

                    width: "1030px", //width: placeholderDiv.offsetWidth,

                    height: "830px", //height: placeholderDiv.offsetHeight,

                    hideTabs: true,

                    hideToolbar: true,

          "Customer Segment" : "Consumer",

                    onFirstInteractive: function () {

                          workbook = viz.getWorkbook();

                          activeSheet = workbook.getActiveSheet();

                    }

              };

              viz = new tableauSoftware.Viz(placeholderDiv, url, options);  

          }

          • 2. Re: Tableau API to select filter values based on user login-in
            Relevant

            thanks Santiago but that does not answer my question.

             

            you explicitly passed "Consumer" to your filter "Customer Segment". I don't want to do that.I want tableau server to pick one from the list of "Customer Segment"; i dont care if the first one is picked or any one in random.

             

            I am needing to set a default value to my filter Region. Different users have access to different Regions so I cannot set a Fixed value neither can i set it to all. I just need the workbook load on the first value or any random value from the list of Region available for that user.

             

            Let me know if it does not make sense.

             

            Edit:  I know the URL in my initial question is not valid, that was just an example.

             

            Thanks,