2 Replies Latest reply on Aug 3, 2017 10:59 AM by Shane Meyers

    Assigning Multiple Values to Same Response in Calculated Field?

    Shane Meyers

      Using Tableau 10.1. I'm trying to create a filter for my visualization, but the way my data is structured makes it difficult. The data is confidential, but I'll provide an example that illustrates the problem. Let's say survey respondents were asked which sports teams they are fans of. They were allowed to check off as many of the following boxes as they'd like:


      1. Florida Gators

      2. Miami Dolphins

      3. Jacksonville Jaguars

      4. Miami Marlins

      5. Florida Panthers

      6. Tampa Bay Devil Rays

      7. Tampa Bay Buccaneers

      8. Miami Heat

      9. Tampa Bay Lightning

      10. Orlando Magic


      The way my survey data is coded just gives me responses like "1,4,7,9", "4", "5,7,8" and so on. Obviously there are a ton of different combinations of responses. I'd like people interacting with my visual to be able to filter by response. So they could check a box that says "Florida Gators" and then only see data for responses that contain "1" in the string. If they then also checked a box that says "Miami Heat", they'd see responses for responses that contain "1" and/or "8" within the string. My rough go of creating a calculated field that would allow this is as follows:


      IF CONTAINS([Q25], "1") THEN "Florida Gators"

      ELSEIF CONTAINS([Q25], "2") THEN "Miami Dolphins"

      ELSEIF CONTAINS([Q25], "3") THEN "Jacksonville Jaguars"

      ###repeat for remaining survey questions



      I don't think this format for a calculated field would work for a number of reasons, but chiefly because of the way I've ordered the code? All strings containing "1" would be labeled as Florida Gators. From there, all remaining strings (the ones that don't contain "1") that contain "2" would be labeled Miami Dolphins. From there, all remaining stings (those that contain neither 1 nor 2) that contain "3" would be labeled Jacksonville Jaguars. I think it's clear that this is not what I want from my filter. If checked off the filter box that says "Miami Dolphins", my visualization would exclude Dolphins fans who are also Gators fans. Can anyone offer advice for how I can solve this problem? Let me know if clarification is needed as I'm relatively new to Tableau and I'm not sure that I asked this question in a way that is either concise or clear. Thanks!