2 Replies Latest reply on Jan 15, 2015 6:14 AM by Julien Nicault

    How to combine applyRangeFilterAsync and applyFilterAsync?

    Julien Nicault

      Hi,

       

      I have the case where I need to filter a date range and another criteria on a dashboard.

       

      Here's the code that filters the date range :

       

      function applyDateFilter(startDate, endDate, target) {

         sheet = target.getWorkbook().getActiveSheet();

         var filterOptions = {

         min: startDate,
         max: endDate

        };

         if (sheet.getSheetType() === 'worksheet') {

         sheet.applyRangeFilterAsync("Action Date", filterOptions);
         } else {

         worksheetArray = sheet.getWorksheets();

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

         worksheetArray[i].applyRangeFilterAsync("Action Date", filterOptions);


         }

        }

      }

       

      And here's the code that filters out a value from a list of categories (by default, all the categories are selected in the Tableau filter):

       

      function dontShow(filterName, values, target) {

         sheet = target.getWorkbook().getActiveSheet();

         if (sheet.getSheetType() === 'worksheet') {

         sheet.applyFilterAsync(filterName, values, 'REMOVE');
         } else {

         worksheetArray = sheet.getWorksheets();

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

         worksheetArray[i].applyFilterAsync(filterName, values, 'REMOVE');
         }

        }

      }

       

      Both functions work fine individually, but when I try to apply a date range and filter out a category, I get nothing back.

       

      What am I doing wrong?

       

      Cheers,