3 Replies Latest reply on Apr 24, 2019 10:30 AM by Ben Newell

    How to determine that the (All) filter was selected with the javascript api?

    Chris Weber

      With the javascript api, we can detecte changes to the filters via addEventListener with FILTER_CHANGE.


      This works fine.


      The issue is that there doesn't seem to be a way to determine that the (All) filter has been selected vs multiple selections (where allowed).


      We can use the filter event (filterEvent.getFilterAsync()) to get the filter, in this case a CategoricalFilter so we can use getAppliedValues() to get a list of all applied values.


      However, without then comparing that list to EVERY available filter, how would we know that the special  (All) filter has been selected?


      As an example, use this sample:
      Respond to Events - Tableau




      How could you detect that the the (All) filter was selected?



        • 1. Re: How to determine that the (All) filter was selected with the javascript api?
          Patrick Van Der Hyde

          Hello Chris,


          I have passed this question to a few team members to see if they can assist.  My reply will also bring this thread to the top of the current questions again. 



          • 2. Re: How to determine that the (All) filter was selected with the javascript api?
            Keshia Rose

            Hi Chris,


            There is currently no way of doing this with the Javascript API. One workaround you could do is to have a dummy sheet on your dashboard that is hidden (1px by 1px) and use that to get the full domain of the filter. Another way, though much slower, would be to set the filter to ALL and get the domain that way then return to the original state. We are currently planning some upgrades to the Javascript API that would improve this and make things more similar to the Extensions API, but those will not be released for some time.


            Take care,


            1 of 1 people found this helpful
            • 3. Re: How to determine that the (All) filter was selected with the javascript api?
              Ben Newell

              Hi Chris!


              Another route you could go (if you didn't need to repeat this for a ton of workbooks) is:


              Create your filters using JavaScript and the getData() function. Then create a function that identifies what has been selected from the HTML object


              Here is sample code to create a filter:


              //add (all) item to array

              var filterList=['(all)'];


              function setFilterData(){

                 console.log('Fetch data to populate dropdowns:');

                 //Query your Workbook for the sheet that has your data

                 tableauViz.getWorkbook().getActiveSheet().getWorksheets().get("[YOUR WORKSHEET]").getSummaryDataAsync().then(function(data){

                 var dataArray= data.getData();

                 for(var i = 0; i < dataArray.length; i++){

                 //I have dataArray[i][0] because the data i'm after is in the first child. You may need something different

                 var portName = dataArray[i][0].value;

                 //If value I'm after is not in array, then added it

                 if (filterList.indexOf(portName)==-1){







              //Create HTML object for each item in array and add to HTML drop-down

              function addPortListToFilter(filters){


                 for(var cnt = 0; cnt < filters.length; cnt++){

                 var ItemOption = document.createElement('option');


                 document.getElementById("[YOUR HTML FILTER]").appendChild(ItemOption);




              Then you just add an "onClick" function to be:

              var selectedValue=document.getElementById("[YOUR HTML FILTER]").value


              if (selectedValue='(all)') {