5 Replies Latest reply on Nov 1, 2018 7:45 AM by soni s

    Change in Parameter value list based on line of business

    soni s

      HI Guys,


      I have a requirement where we use parameter to filter values. These values are different for different line of business. Not all businesses have all the values listed in the parameter. Is there a way to hide the value in the list if that value is NULL for the line of business.


      e.g.  I have furniture, Office supply and technology line of business. I have created parameter sub-category.


      1. A

      2. b

      3. c

      if furniture doesn't have value b, then in the parameter list for furniture, b should not show up in the list. Is it possible? We have 3 different workbooks for 3 different line of businesses. When we promote these workbooks for different line of business, I want the parameter list to be updated based on line of business.

        • 1. Re: Change in Parameter value list based on line of business
          Cédric Tran

          Dear Soni,


          According to me, there no way to turn a Parameter into a Dynamique Parameter because it looks like it is just a flat list, that you can manually fill or fill once with the content of a dimension.


          May I suggest you a work around: Create a Viz with your subcategory as a flat list with your filter and use this list in a Dashboard to control the other Viz of the Dashboard. By this way, the first Viz will act like a dynamic list of the available subcategory



          • 2. Re: Change in Parameter value list based on line of business
            soni s

            Actually I am combining multiple measures to create a parameter. and not all measures are present for all the line of businesses.







            Can your workaround will work for this use case?

            I dint understand the solution. Would you mind posting a workbook?


            Thank you so much!!


            • 3. Re: Change in Parameter value list based on line of business
              amar savale


              Marked as Correct or Helpful if it is Working.

              Parameters are one of the most loved features of Tableau. You can use them in calculations, across multiple datasources, in titles and labels, and in countless other ways.

              Unfortunately, they are static. Unlike filters, parameters are a set list of values. You can build them based off of a field, but if that field changes, the parameter keeps the old values.

              In many cases, a filter can be used instead of parameters to alleviate this problem, but there are many cases where a parameter is necessary.

              Luckily, using the power of the JavaScript API, there is a solution! Using a combination of a filter and a parameter, we can easily use a dynamic filter to set a parameter’s value. This parameter can then be used for blending across multiple data sources, calculations or whatever magic you want to implement! This tutorial assumes a basic knowledge of the Tableau JavaScript API, but if you have not used it already, Tableau has agreat tutorial for getting started.

              How It’s Done

              I’ve attached an example, so feel free to dive into that now if you feel comfortable. If you’d like more information, let’s run through the pieces.

              On the Tableau Desktop side, setup couldn’t be easier. Simply make a parameter of “string” type and use it in the areas where you would like to use the dynamic parameter’s values. For the end user to select, instead of the parameter, use your dynamic field as a “single value” quick filter. The parameter’s default value can be whatever you like (usually All or similar to match the quick filter).

              For the JavaScript side, you’ll need to do some programming – but it couldn’t be simpler! The example is built in jQuery, but if you are using a different JavaScript library, feel free to substitute out the various functions for whatever you need.

              First, we need a function to run on the page load to instantiate our visualization. This function will set up our visualization, assign it to a variable and hook it to a function that is called when a filter is changed.

              /** * Instantiate our vizualization. */ $(function() { var url  = 'http://interworks.com/#/site/NA/views/TestParam/Dashboard1'; var vizOptions = { showTabs           : true, hideToolbar        : true, width              : "420px", height             : "420px" };  currentViz = new tableauSoftware.Viz(document.getElementById('viz'), url, vizOptions); currentViz.addEventListener(tableauSoftware.TableauEventName.FILTER_CHANGE, onFilterChange); }); 

              Next, we need a function to process our filters and assign one to our parameter. I used the Region field and a parameter named MyDynamicParam. Adjust these as needed. I also added a small piece of code to set the parameter to All when the All option is selected instead of a single region.

              /** * Catches the tableau event fired when a filter is changed. */ function onFilterChange(e) { if (e.getFieldName() == 'Region') { e.getFilterAsync().then(function(filter) { var values = filter.getAppliedValues(); var value = values[0]['value'];  // Value of the parameter if "All" is selected in the filter. if (values.length > 1) { value = 'All'; }  currentViz.getWorkbook().changeParameterValueAsync('MyDynamicParam', value); }); } } 

              And there you have it! Quick, simple, dynamic parameters using Tableau. All you need to do now is create some content!

              • 4. Re: Change in Parameter value list based on line of business
                Cédric Tran



                On a Dashboard, the ACTIONS option let you choose which DataSheet or Dashboard you want to filter with your primary filter.


                Please check the attached Dashboard ;-)



                • 5. Re: Change in Parameter value list based on line of business
                  soni s

                  Where do you initiate this javascript? is it done on webpage? I am not clear on how we link these two.