8 Replies Latest reply on Feb 14, 2020 10:14 AM by Deepak Rai

    Set Actions: How to cumulatively add to set from multiple sheets

    William Moir

      Hi all,

       

      I have a dashboard with a map of towns and a bar chart of the same towns. Both are colored according to the same measure, and the bar chart will be sorted descending on this value as well. I want the following to happen when you click on a town in the map or bar chart: 1. the town gets highlighted on the map; 2. the town does not get highlighted on the bar chart; 3. the town moves to the top of the list in the bar chart. I also want to allow multiple selections, and in particular multiple selections regardless of the source sheet. For example, if you click on a town in the map, then a different town in the bar chart, both should be highlighted in the map, and both should be moved to the top of the bar chart.

       

      I attempted to do this using Set Actions, but it does not quite work. What I did was create a Set of town names, and a Set Action with the map and bar as source sheets. However, selecting towns on the map will add those towns to the set, and then selecting towns on the bar chart will add those towns separately to the set. See the following screenshots for an example:

       

      1. Two towns select on the map, both are highlighted and moved to the top of the bar chart.

       

      2.Two additional towns selected in the bar chart. The map highlighting is correct, but the set now only contains the two new towns (the first two towns selected from the map are no longer at the top of the bar chart). The desired behavior is that all four towns will also be at the top of the bar chart.

       

       

      3.Selected an additional town on the map. The first two towns selected from the map are now at the top of the bar, and the two towns selected from the bar chart are not highlighted, and not at the top of the bar. The desired behavior is that all 5 towns will be highlighted on the map, and at the top of the bar.

       

      Does anyone have any ideas for how to get the behavior I want? I feel like either I'm making some basic mistake, or there is a bug, because I can't imagine any scenario where you would want the behavior I'm seeing.

       

      Attached is a twbx.

       

      Thanks!

       

      Will

        • 1. Re: Set Actions: How to cumulatively add to set from multiple sheets
          Deepak Rai

          You need a Combined Set to Combine all Values. I Created a Set2 which Adds your Selections from Multiple Sheets. Now You please play ,to Set up that in your MAP. I selected 7 Cities and all are being shown everywhere. Add more and they are getting added, so play and adjust .

          Thanks

          Deepak

          If it Helps, Pl mark it helpful and CORRECT to Close Thread

          • 2. Re: Set Actions: How to cumulatively add to set from multiple sheets
            Simon Runc

            hi William,

             

            So your not making any basic mistake, and neither is it a bug. It's just the way set actions have been implemented. I agree I'd quite like some extra options on the "when mark is deselected" so users can retain the previous entries, and then click again to add another. A set reset button would also be nice!

             

            However we can achieve this via parameter action, where this multi-select trick is well explained here

            https://drawingwithnumbers.artisart.org/tag/parameter-actions/

             

            So first I created a blank string parameter, with "any" entry allowed.

             

            Next I create this field and add to all the views

            [Append Town]

            [Selected Towns] + '|' + [Town Name]

             

            Then I create this field which looks at the parameter list and determines if a town is in there

            [Selected Town]

            contains([Selected Towns],[Town Name])

             

            this is like your In/Out set.

             

            The final thing to get the map highlighting to persist (btw highlighting is an action so when the user un-clicks the highlighting is lost).

             

            I created this field

            [Geometry - Non Selected Town]

            if not([Selected Town]) then [Geometry] end

             

            and used this as the geography for a second (dual) axis on the map. I set colour to gray, and lowered the transparency. This has the affect of putting a "mask" over the map, with holes where selected Towns are. You could do a similar thing for the bar chart

             

            If you read the blog you'll also see how to add a reset button.

             

            Hope that makes sense, and helps

            1 of 1 people found this helpful
            • 3. Re: Set Actions: How to cumulatively add to set from multiple sheets
              William Moir

              Thanks Deepak! That worked perfectly. Not sure how I missed Combined Sets, guess I should have read the documentation before posting.

              • 5. Re: Set Actions: How to cumulatively add to set from multiple sheets
                William Moir

                Thanks Simon! I marked Deepak's answer as correct because his response came in first, and it does get my desired behavior. But your trick is definitely a nice tool to have, and I'm sure I'll find situations where I'll have to use it.

                 

                I also like your solution for getting highlighting to persist. I've had that issue in a different situation, and I used a similar solution to add a selected flag to color shelf and manually setting unselected colors to look "unhighlighted" which is much more tedious than your "mask". I was already using the dual-axis for something else, but again I'm sure I'll be able to use your solution in the future.

                • 6. Re: Set Actions: How to cumulatively add to set from multiple sheets
                  Simon Runc

                  My pleasure. It was an interesting problem, In Tableau (as with most things) there are usually a few ways to solve it and I hadn't actually considered Deepak's combined sets method (so I learned something new, myself).

                   

                  Glad you found the "mask" useful. As you use Tableau more and more, being (essentially) a data-driven drawing canvas, there is a lot of "smoke and mirrors"

                  • 7. Re: Set Actions: How to cumulatively add to set from multiple sheets
                    William Moir

                    Just adding an update in case anyone is following this. While Deepak Rai combined set solution solved my problem, the workbook he attached didn't quite work in the way I wanted, so attached is my implementation of it (dashboard named "Highlight Action"

                     

                    There are a couple issues:

                     

                    1. If you deselect by clicking in the whitespace in the map or bar chart, it only removes the items from the respective set, not all the items from the combined set.

                     

                    2. If you deselect by clicking in the whitespace in the map, the highlight gets reset, so combined with issue 1 if you selected any towns from the bar, they will remain selected in the bar, but not highlighted in the map.

                     

                    A workaround is to clear the selection by pressing escape, which clears both sets.

                     

                    I also made a dashboard with a partial implementation of the mask solution from Simon Runc for persisting the highlight on the map (dashboard named "Mask Not Working"). It is partial because ctrl-clicking to select multiple towns doesn't work - you can select two towns this way, but when you try to select a third it replaces the second, and so on. I'm guessing this might be because when make the first selection, the rest of the map gets covered by the "mask" on the dual-axis, and all further clicks are on these geometries, although I'm not sure why that would break it.

                     

                    Thanks again to Deepak and Simon!

                     

                    Will

                    • 8. Re: Set Actions: How to cumulatively add to set from multiple sheets
                      Deepak Rai

                      Good to Know, that's why I suggested you to play with it as it's your baby and you know it better.