1 Reply Latest reply on Aug 2, 2018 9:50 AM by Mike Labman

    applyFilterAsync not applying to all worksheets

    Mike Labman

      I have a web portal which embeds ~ 20 workbooks and controls them with an HTML dropdown.


      I've declared the viz using the standard declaration viz = new tableau.Viz(containerDiv, 'http://my.tableau.server/viz/dash');


      The code which filters the viz, looks like this:


      var worksheet = viz.getWorkbook().getActiveSheet().getWorksheets().get("Market_Name");

      worksheet.applyFilterAsync("market", ["Market One","Market Two"], "replace");


      The dashboard has 3 charts on it and one simple text Viz which displays the current state of the "market" filter.   This "market" filter has been applied to all worksheets using related data sources.


      But, when the Javascript call is made, the text Viz shows Market One, Market Two - but the charts are not updated.


      If instead of using the filters, I re-initialize the viz with the following code,  it works properly:



      viz = new tableau.Viz(containerDiv, 'http://my.tableau.server/viz/dash?market=Market One,Market Two")


      This works perfectly - but it's not as user-friendly because the whole viz disappears and is replaced.  Ideally, I would just like to use the applyFilterAsync function as it was meant to.   I've also tried using  viz.refreshDataAsync(); but that doesn't help - it just makes the workbook refresh the same un-updated data/view


      Thanks in advance

        • 1. Re: applyFilterAsync not applying to all worksheets
          Mike Labman

          My current, new workaround is this:


          var worksheets = viz.getWorkbook().getActiveSheet().getWorksheets();

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

               worksheets[i].applyFilterAsync("market", ["Market One","Market Two"], "replace");


          I don't like this at all but it performs more smoothly than reloading the whole viz.   It seems like, since the filter is applied to every worksheet, that changing it once would change it globally.