11 Replies Latest reply on Sep 6, 2018 4:13 PM by Keshia Rose

    getFilters isn't returning all values

    Ankit Patel

      Hi,

       

      I have dashboard with a series of filters, in which I incrementally reduce my data down using "relevant" values.

      The values that are left in my final filter are what I'd like to extract using the getFiltersAsync() method.

      If I leave all of the values selected, then the API doesn't seem to recognize that final filter, meaning no filter-values are returned. If I go in and select just a few of the values, then the API seems to recognize and retrieve the subset values in that final filter.

       

      Is this how the functionality was built for this method? Or am I missing something?

      Could I go into the source code of the API and change anything to ensure that the method retrieves all of the values selected in a filter (even if ALL values are selected)? Or is the retrieval functionality stored somewhere else away from the API source?

       

      Tableau Desktop version =  2018.2

      Tableau Extensions library = tableau-extensions-1.latest.js

       

      Would appreciate any guidance. Thanks in advance!

        • 1. Re: getFilters isn't returning all values
          Keshia Rose

          Hi Ankit,

           

          Yes, you are correct that this is the current functionality for the method. We do have plans to change this but not sure when you will be able to see it in-product.

           

          Take care,

          Keshia

          1 of 1 people found this helpful
          • 2. Re: getFilters isn't returning all values
            Ankit Patel

            Hi Keshia,

             

            I appreciate your prompt response. Thanks for verifying the current functionality.

            If I wanted to go through the source code to try and make changes myself to grab everything that is checked off in a filter, would I be able to do that?

             

            I have been poking around a bit already, and can't seem to find/isolate exactly where the value pulling process takes place. Is the code for that process hosted elsewhere?

             

            Thanks,

            Ankit

            • 3. Re: getFilters isn't returning all values
              Keshia Rose

              Hi Ankit,

               

              The change that would need to take place is not at the external API layer so no, you would not be able to make this change as you would have to go into our compiled c++ binaries. What outcome are you trying to achieve, perhaps there is a workaround using one of the get data methods?

               

              Take care,

              Keshia

              • 4. Re: getFilters isn't returning all values
                Ankit Patel

                Hi Keshia,

                 

                I have a set of filters that point to the same dataset and are hierarchical in nature.

                As I make selections in the higher-level filters, the subordinate filters then update with the relevant values. Ultimately the final filter shows only the values that are important to me, and I’d like to be able extract all of the values there.

                 

                For example (the following filters have these values checked off):

                Category: Cheese

                Subcategory: Cream Cheese

                UPC: (all), 12345, 67890, 11121, 31415, 16171

                 

                Let’s say I picked Cheese and then Cream Cheese as my first two filters, I am then left with the only five total UPCs in the Cream Cheese universe. I’d like to retrieve all five of those values instead of choosing one of two of them.

                 

                Using the API, I’d get back the values “Cheese” and “Cream Cheese” when iterating over the first two filters. But I’d get a blank from the UPC field (maybe because the c++ binaries have a logic built into them which assume ALL or NONE values imply no filtering activity happening, and therefore ignore it's values?).

                 

                Is there a workaround where I’d be able to retrieve those five UPCs, when ALL of the values are left selected?

                 

                -Ankit

                • 5. Re: getFilters isn't returning all values
                  Keshia Rose

                  Hi Ankit,

                   

                  Could you use getUnderlyingDataAsync() to get those values?

                   

                  Take care,

                  Keshia

                  • 6. Re: getFilters isn't returning all values
                    Ankit Patel

                    Hi Keshia,

                     

                    Thanks for the suggestion, I tried adapting the sample code from the git docs and tried to run this:

                     

                    function get_upcs(){
                    let list = "start";
                    
                    tableau.extensions.dashboardContent.dashboard.worksheets.find(w => w.name === "product 1").getUnderlyingDataAsync().then(dataTable => {
                    list += dataTable.name;
                      let field = dataTable.columns.find(column => column.fieldName === "upc1");
                      for (let row of dataTable.data) {
                        list += row[field.index].value;
                      }
                    
                    });
                        return list;
                      }
                    

                     

                    It doesn't even seem to allow me to get the dataTable.name attribute, the only thing that gets returned is the original "start" string that I initialized the list variable with.

                    I'm certain that sheet exists and so does the field name. The field name is represented the same way in the datasource as well as on the worksheet.

                     

                    Am I doing something wrong?

                     

                    Thanks,

                    Ankit

                    • 7. Re: getFilters isn't returning all values
                      Keshia Rose

                      Hi Ankit,

                       

                      The getUnderlyingDataAsync() method is asynchronous and therefore your return will not wait for it to finish before returning "list". In order to make sure getUnderlyingDataAsync() is done before doing anything with "list" you should take action within then(). However, get_upcs() will never see the return if you place it inside of then(), instead, it is only available for the next then(), if you call one. Therefore, you should do whatever work you want to do with the results directly, i.e.:

                      function get_upcs() {
                          let list = "start";
                          tableau.extensions.dashboardContent.dashboard.worksheets.find(w => w.name === "product 1").getUnderlyingDataAsync().then(dataTable => {
                              list += dataTable.name;
                              let field = dataTable.columns.find(column => column.fieldName === "upc1");
                              for (let row of dataTable.data) {
                                  list += row[field.index].value;
                              }
                              other_function(list);
                          });
                      }
                      

                       

                      Take care,

                      Keshia

                      • 8. Re: getFilters isn't returning all values
                        Ankit Patel

                        Hi Keshia,

                         

                        That didn't work for me either. I couldn't even get the name attribute to pass through to another function where I could work with it.

                        I think I've reached a point where this API probably isn't the right solution for my production needs and I'll have to find a work around.

                        You've been very helpful!

                        Thanks again!

                        -Ankit

                        • 9. Re: getFilters isn't returning all values
                          Keshia Rose

                          Hi Ankit,

                           

                          Can I ask what your end goal was? What were you trying to do?

                           

                          Take care,

                          Keshia

                          • 10. Re: getFilters isn't returning all values
                            Ankit Patel

                            Hi Keshia,

                             

                            The ultimate goal of this was to create an API triggering mechanism using a Tableau frontend. I've been able to do this using the URL actions when I have a set of (relevant value) filters on a dashboard resulting in just one group of UPCs, which get submitted as parameters in the API call.

                             

                            I'm now trying to scale this so I can have four sets of UPCs. Each set of filters would reference the same datasource. I'm duplicating the original set of filters across four sheets and using relevant filtering applicable only within each respective sheet. However, when I try to build the URL action, I can only include the UPC filter values from one sheet, data from multiple sheets seemingly can't be packed into one URL action.

                             

                            After reaching out to the support team, they couldn't help with my original method and recommended I try Tableau extensions. Extensions have the ability to grab data from all filters on all sheets and from there I can build the API link, and call it using javascript behind the scenes.

                             

                            Unfortunately, as you know from my original question, I'm almost there, except for the situations where I can't get any values back from the UPC field when I leave them all checked off.

                             

                            Thanks,

                            Ankit

                            • 11. Re: getFilters isn't returning all values
                              Keshia Rose

                              Hi Ankit,

                               

                              I see. I still think the extension API would work for you, using getSummaryDataAsync() or getUnderlyingDataAsync(). These would return the UPCs that remain after all the relative filtering. Were you using the debugger to see if there were any other issues? Either way, I hope you find a solution that works for you!

                               

                              Take care,

                              Keshia