1 Reply Latest reply on Sep 18, 2018 7:44 AM by Man Tsui

    Applying filters on a Dashboard

    tharun kumar

      Is there any way where we can directly apply filters on the dashboard without iterating the sheets of the dashboard

       

      For now I am doing this way:

       

      worksheet = viz.getWorkbook().getActiveSheet().getWorksheets();

       

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

       

                worksheet[i].applyFilterAsync(name, value, 'ADD')

       

      }

        • 1. Re: Applying filters on a Dashboard
          Man Tsui

          This is my strategy for dealing with categorical filters (not time/range/continuous based filters).

           

          The strategy I employ is:

          1) Defining fixed set of viz objects (Tableau Dashboards) in javascript.

           

          2) Create a re-use-able javascript function to apply filters based on (a) input viz object, (b) target sheet name, (c) filter name, and (d) list of filter values.

               // ***** Sample javascript code ***** //

               // Filter the specified dimension to the specified value(s)

               function setFilterTo(vizName, sheetName, filterName, values) {

               var sheet = vizName.getWorkbook().getActiveSheet().getWorksheets().get(sheetName);

                   sheet.applyFilterAsync(filterName, values, tableau.FilterUpdateType.REPLACE);

               }

           

          3) Conduct targeted filter apply to target sheets and dashboards rather than a blanket shotgun approach.

               // ***** Sample javascript code ***** //

               setFilterTo(vizCMS_Cost_Hosp_Stat, 'Hosp Stat Map', 'State', arrayFilterList);

               setFilterTo(vizMedicareIP01, 'IP Map', 'Provider State', arrayFilterList);

               setFilterTo(vizMedicareOP01, 'OP Map', 'Provider State', arrayFilterList);

           

           

          My sample file

          https://github.com/mantsui/Tableau_Web_Portal01/blob/gh-pages/Tableau_JS_Embed.js

           

          Sample dashboard portal with targeted filter passthru

          3 dashboards <Medicare Cost Report: Hospital Statistics>, <Medicare Inpatient Charge Analysis>, <Medicare Outpatient Charge Analysis> interacting/synchronizing through the "State" filter

          https://mantsui.github.io/Tableau_Web_Portal01/