3 Replies Latest reply on May 1, 2014 5:57 PM by Nay Lin Soe

    javascript select all marks

    Nay Lin Soe



      In Javascript API, has anyone tried querying what dimensional values are included in a filter? For eg,


      In the above, depending on what you select on the filter (Locality), the membership of the dimension Village will change. What I like to find out is, given the filter, at any one time, I like to know what values are included in Village dimension. UPDATE: My ultimate goal is to use that to filter on another div that contains a dashboard.


      I thought of an indirect approach of

      1. selecting all the marks (JS triggered)

      2. in the SelectMarksEvent raised, get the values of Village dimension


      However, I can't find any way of selecting all the marks (1) via JS. In JS filtering, you could use tableauSoftware.FilterUpdateType.ALL as an argument to indicate you intend to include all values in the filter. There is no equivalence in Select. Similar question has been asked in Javascript API - Get all marks in a Viz


      So I am back to square one: how do I get the values of Village dimension at any one time?


      Any insight/experience you are able to share will be greatly appreciated.



        • 1. Re: javascript select all marks
          Russell Christopher

          Hi Nay -


          You're correct, there is no way to get a list of "all" values, only the values that have changed. So your idea is a good one.


          However, I'd begin to wonder whether it might not just be a bit easier to fire a good old-fashioned query directly at the data source yourself to get this information? It might end up saving you time...and would certainly take less work-around code

          1 of 1 people found this helpful
          • 2. Re: javascript select all marks
            Justin Rockwood

            Russell's approach will ultimately work. However, I think there's a way you can do this in the API as well. Try using the CategoricalFilter.getAppliedValues() method, which returns an array of DataValue objects. That should do what you want. The code would look something like this (forgive me if this doesn't "compile" - I'm writing it on the fly)...


            var worksheet = viz.getWorkbook().getActiveSheet(); // assumes this is a Worksheet object

            worksheet.getFiltersAsync().then(function (filters) {

            var filter = filters.get("FieldNameOfFilterIWant");

            // This has to be a categorical filter to get the applied values.

            if (filter.getFilterType() === tableauSoftware.FilterType.CATEGORICAL) {

               // This returns an array of DataValue objects, which has two fields: value and formattedValue.

               var values = filter.getAppliedValues();

               // You now should have what you want.



            • 3. Re: javascript select all marks
              Nay Lin Soe

              Thanks Justin. That's what I am looking for.