6 Replies Latest reply on Jun 14, 2016 9:49 AM by anastasia aourik

    Apply multiple filters Async

    Aditya Goel



      I have a set of filters to be applied on a workbook using JS API. For example:

      Dimension1, values: ["A", "B", "C"]

      Dimension2, values: ["D","E"]

      Measure1, values: ["20","500"]


      Here's the JS code that I have:

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

            switch (filters[i].filterType) {

              case ("categorical"):

                sheet.applyFilterAsync(filters[i].fieldName, filters[i].filterValues, tableau.FilterUpdateType.REPLACE);


              case ("quantitative"):

                sheet.applyRangeFilterAsync(filters[i].fieldName, {"min": filters[i].filterValues[0], "max": filters[i].filterValues[1]});





      Problem is this does not work if there are more than 1 filters to apply. That is, if I pass 2 filters in the "filters" variable, nothing happens. The view sort of stops working, no interactivity, no tooltips after that.


      I understand there's the "then" function to be used for async calls but then number of filters can be anything.


      Is there a better way of doing this?