10 Replies Latest reply on Sep 16, 2016 5:20 AM by Yunus Gittham

    Changing a header based on filter values

    Yunus Gittham

      Hi

       

      I have a section header in my dashboard which should change based on filter selections.

       

      I have attached the below screenshots to show what I have done but it does not behave the right way.

       

      When i select "ALL SITES" or  "(All)" it should show "Strategy A3s'" else it should show "Action Plan A3"

      See picture 3 where it does not work as expected. What do I have to change?

       

      1. Works as expected

      2. Works as expected

      3. Not Working as expected as i only want one value at a time.

       

        • 1. Re: Changing a header based on filter values
          Michael Hesser

          Hello Yunus;

           

          I think your calculations aren't working because you're using filters, and the filter for "ALL" doesn't represent the word "ALL", but rather the set of all choices.

           

          Now there are many different ways to handle this (you might be able to do a countd of a filter, for example), but I prefer using a parameter rather than a filter. I like this idea bestbecause it gives you a lot of control over other calculated fields.

           

          You can learn all about it here:

          https://www.interworks.com/blog/tmccullough/2014/04/25/using-parameter-filter-and-retaining-all-value

           

           

          I hope this helps!

           

          You can create a calculation that is equivalent to your parameter to mirror a dynamic column header; you can also use the parameter to get a dynamic title.

          • 2. Re: Changing a header based on filter values
            Joe Oppelt

            ALL (or (All) ) isn't an actual quick filter value.  It's a special feature Tableau adds in there for you.  You can't check for "All'.

             

            There are a lot of things you can do to know if your user has selected ALL, though.  Some of it depends on what you are actually doing in your sheet.

             

            A packaged workbook (even if you just hack up something that simulates what you are doing) will be helpful to show you ways to address this.  But one thing you can do is create a LOD that finds how many unique values are in the data (before filtering) and then do a COUNTD of what you actually have on your sheet.  If they match, your user selected ALL.


            Another thing you can do, if your quick filter is set to "Single Value List", and if you also display the ALL feature, then if COUNTD is more than 1, the user had to have selected ALL.

             

            So you make a calc to determine this, and if your CALC detects ALL, then set your [vStrategy] switch accordingly.

            • 3. Re: Changing a header based on filter values
              Joe Oppelt

              Michael -- I often do this too.  Parameter list starts with ALL, and then has all the individual choices.

               

              The problem with this is that you can't have a multi-select functionality here.  If the design calls for one-or-ALL, then this is a great way to go.  Otherwise, other approaches are needed.

              • 4. Re: Changing a header based on filter values
                Michael Hesser

                Excellent points, Joe Oppelt!

                Also important: parameters aren't dynamic, meaning if you have new data you want to sort on (such as you just received data from 2017), you'll need to reset parameter values. (Please don't giggle-- I'm saying this to remind MYSELF more than tell you something you already know! I'm getting to be an old man and forget these things! )

                • 5. Re: Changing a header based on filter values
                  Yunus Gittham

                  Hi Joe

                   

                  Attached is a sample workbook based on superstore data set

                  • 6. Re: Changing a header based on filter values
                    Yunus Gittham

                    Joe Oppelt

                     

                    I also did the below two calculations

                     

                    segment_calc = {fixed : countd([Segment])}

                    segment_selected = WINDOW_COUNT(COUNTD([Segment]))

                     

                    but when i put into a variable vActionSwitch = if ( [segment_calc] = [segment_selected] ) then "strategy" else "action" end

                    i get an error "cannot mix aggregate and non-aggregate arguments"

                    • 7. Re: Changing a header based on filter values
                      Joe Oppelt

                      See attached.

                       

                      In Sheet 1 I created two calcs.  [Segments in Database] counts how many segments are in the database, regardless of filters.

                       

                      [Segments Selected] counts how many are actually selected in the sheet.

                       

                      I placed the values in the title so you can see what is happening in there.  (Note that I had to put [Segment] itself on the sheet so that they are actually there to be counted.)  The [Segments selected] calc is a table calc, and I had to edit the table calc to count along [Segment].

                       

                      Because [Segment] is on the sheet, you are going to get as many repetitions of values as you have segments selected.  Your actual sheet may be displaying segments, and if so, then this is not a problem.  But in this exercise I'm sure you only want one value to be displayed here.


                      So see Sheet 2.


                      This is the same as Sheet 1 except I added an INDEX calc and out it in the filter.  Just get the first iteration of whatever is getting displayed.

                      1 of 1 people found this helpful
                      • 8. Re: Changing a header based on filter values
                        Yunus Gittham

                        Hi Joe Oppelt,

                         

                        Thank you for the suggestion. It worked !!

                        • 9. Re: Changing a header based on filter values
                          Kaz Shakir

                          Give this a try and see if it works for you.  Create two calculated fields as follows:

                          Calculation1

                          IF STARTSWITH([Facilityextendedname], “ALL”)

                          THEN 1

                          ELSE 0

                          END

                           

                          vStrategyActionSwitch

                          IF SUM(Calculation1)>0

                                          THEN “Strategy
                          A3s”

                                          ELSE “Action
                          Plan A3”

                          END

                           

                          Please post a message back to let us know if this works for you or not.

                          • 10. Re: Changing a header based on filter values
                            Yunus Gittham

                            Hi Kaz

                            This does not work, because ALL is treated differently. I tried it.

                             

                            The approach suggested by Joe Oppelt works.

                             

                            Thanks All for helping out.