3 Replies Latest reply on Oct 12, 2015 12:21 PM by Jerry Daru

    How to set filters on a displayed dashboard

    Jerry Daru

      Here's my issue:

      I'm trying to set filters on a displayed dashboard, and cannot seem to find the right way to reference the sheet that the filters actually exist on.

       

      Has anyone pulled off anything like this? I don't want to display the base sheet to the users, so activating that one would not work for me I assume...

       

      I have an activeSheet.getWorksheets() and see that both of my sheets are contained there. I have two filters I want to set and they are pulled from sheet[0] and apply to all other sheets on the workbook.

        • 1. Re: How to set filters on a displayed dashboard
          Jerry Daru

          I am able to reference the sheet using activeSheet.getWorksheets[0] and call the applyFilterAsync method, but it apparently doesn't do anything.


          function tableauLoad(stringArgs) {

               console.log("open Tableau stuff");

               console.log(stringArgs);

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

               var url = "http://TheServer/#/views/MyWorkbook" + stringArgs.chartToDisplay[0];//Address of first sheet in workbook

               var options = {

                    hideTabs: false,

                    width: "100%",

                    height: "100%",

                    onFirstInteractive: function () {

                         workbook = viz.getWorkbook();

                         activeSheet = workbook.getActiveSheet();

                         console.log(activeSheet);

                         console.log(activeSheet.getWorksheets());

                         console.log(activeSheet.getWorksheets()[0]);

                         activeSheet.getWorksheets()[0].applyFilterAsync("FilterOne", stringArgs.filterOne, tableau.FilterUpdateType.REPLACE)

                              .then(activeSheet.getWorksheets()[0].applyFilterAsync("FilterTwo", stringArgs.filterTwo, tableau.FilterUpdateType.REPLACE))

                           }

                      };

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

                      console.log('Viz' + viz);

          }

          • 2. Re: How to set filters on a displayed dashboard
            Tamas Foldi

            This should work. Can you publish the workbook (with dummy data) to public so I can test it on my end?

             

            What is the exact type of stringArgs.filterOne? Can you show me the jsonified values?

            • 3. Re: How to set filters on a displayed dashboard
              Jerry Daru

              Hey Tamas, thanks for the reply. I'll try to put something together for this soon.

              my stringArgs is defined in c# as a

              Dictionary<String, List<String>>

              with values for

              chartToDisplay -> single value for desired chart name (this is used for the url)

              filterOne -> list of string values that represent date/time

              filterTwo -> list of string values that represent data by name to filter

               

              The Dictionary is serialized in a code behind method and referenced in our Asp.net code

               

              Basically I want to filter the objects that were uploaded to our server by name, and by the date/time of the upload in one of three scenarios one to many/one to one/many to one. The last part is where the desired chart comes into play.