4 Replies Latest reply on Jan 10, 2014 1:31 PM by Phillip Burger

    how to check that one dataset is contained in another

    George T

      I am working in Tableau 8.1. I have two equal-sized lists of distinct names.  How do I check that all elements from a list is contained in the

      other list and vice versa?

       

      I am new to Tableau.  Thank you for your help.

        • 1. Re: how to check that one dataset is contained in another
          Phillip Burger

          Hi, G T. Welcome to the Tableau forum.

           

          Attached to this reply a .twbx file. It shows one solution. I use tables here. I can think of maybe a couple of other ways to solve this problem. Using sets might be a way.

           

          For large data sets, the solution I'm submitting might not be efficient compared to other solutions. If your lists are long and performance isn't good, try sets. Maybe another reader will have tips on achieving the best performance.

           

          Open up the attached .twbx and take a look. I also put the workbook on Tableau Public. Here is the approach I used:

          • I connected to two files.  Each file is a separate list and data source.
          • Used a table to join them. This table contains the common elements.
          • Compare count of common elements to count of elements in either of the two other lists. I compared count of common elements to count of elements in list 1 but could have used list 1.

           

          Description of the worksheets:

          • First worksheet shows the Boolean response, True/False.  Showing False in this example since lists do not contain the same elements.
          • Second worksheet contains elements in list 1.
          • Third worksheet contains elements in list 2.
          • Fourth worksheet contains common elements.

           

          In this example, I have three connections for convenience. But only two connections, one for each list, are necessary. Connecting to the data source for list-1, connecting to the data source for list-2, then then applying the table to the connection for list-1 is simpler. I added another data connection to list-1 to show all the elements in the list-1 in the second worksheet. Once the table is applied to list-1, it becomes the common elements.  So, if you apply this example to your data, keep in mind that you can use just two connections.  And, this example is connecting to text data. To keep it simple, I used one file for each list.

           

          Link to workbook on Tableau Public:

          http://public.tableausoftware.com/views/comparing-list-contents-for-same-elements-thread-137463/booleanresponse?:embed=y&:display_count=no

          • 2. Re: how to check that one dataset is contained in another
            George T

            What's the difference between "lists" and "sets" in Tableau?  How do I create a table?

            • 3. Re: how to check that one dataset is contained in another
              Phillip Burger

              "List" is not a structure used in Tableau. Nor is it a word that comes up when talking about things Tableau. When we used the word "list" here, we are using solely because it was introduced in the original question. If you're new to Tableau forget the word.

               

              "Sets" are a structure used in Tableau. I think sets are more intuitive and are the better way to go to solve this problem. I'll try to post a workbook that uses sets to answer the question.

               

              In the meantime, if you download the workbook I posted and refresh the data sources with your own two sample (and simple!) lists of data, you should be able to duplicate the results.

               

              Here is a link to sets in Tableau:

               

              http://onlinehelp.tableausoftware.com/current/pro/online/en-us/help.htm#sortgroup_sets.html

              • 4. Re: how to check that one dataset is contained in another
                Phillip Burger

                I tried solving this using sets and groups. Attached is a solution that doesn't return a Boolean True/False and relies on visual inspection to determine if the same elements are contained in both lists. It's another approach but so far I like the table approach because it allows the use of the True/False via a calculated field. The calculated field can then be used elsewhere in the workbook.

                 

                There are a couple of approaches now. Maybe another forum reader might have a third or more elegant solution. 

                 

                If one of these approaches are helpful or answer the question, please mark either "Correct Answer" or "Helpful Answer."