4 Replies Latest reply on Apr 19, 2018 12:25 PM by Robert Abramov

    How to add one filter based on three (or more) columns

    Robert Abramov

      Using this post, I've created a map similar to Example 1, the metro map.  However, I now want to highlight certain "stations" based on multiple columns, where they are non-mutually exclusive.  This may be difficult to type out, so I've included an example below:

       

      In the original post linked above, there are multiple metro lines, with the table below giving the example. 

      LineLine Group (Path ID)Order of PointsStationLatitudeLongitudeTraffic
      111La Défense (Grande Arche)48.8919342.23788314,275,382
      112Esplanade de la Défense48.8878432.2504429,843,051
      113Pont de Neuilly48.8845092.2598926,902,931
      10 BOUCLE101Boulogne-Jean-Jaurès48.8422222.2388363,847,782
      10 BOUCLE102Porte d'Auteuil48.8480742.258648687,237
      10 BOUCLE103Michel-Ange-Auteuil48.8477402.2642972,222,709

       

      On my map, I want to highlight which stations are used by person A, person B, and person C, so I've modified the table to look like this:

      LineLine Group (Path ID)Person APerson BPerson COrder of PointsStationLatitudeLongitudeTraffic
      11YesYes1La Défense (Grande Arche)48.8919342.23788314,275,382
      11YesYesYes2Esplanade de la Défense48.8878432.2504429,843,051
      11YesYes3Pont de Neuilly48.8845092.2598926,902,931
      10 BOUCLE10Yes1Boulogne-Jean-Jaurès48.8422222.2388363,847,782
      10 BOUCLE10Yes2Porte d'Auteuil48.8480742.258648687,237
      10 BOUCLE10Yes3Michel-Ange-Auteuil48.8477402.2642972,222,709

       

      Now I want to add a single filter where one can choose different people (Person A, Person B, Person C, etc.) and their metro stations will be shown, while all other stations will be "gray"-ed out. I can add one filter for each Person, but this defeats the point, especially if there are so many people that the entire left hand side it taken over by filters.

       

      Does anyone know how to create one filter from multiple columns that are non-mutually exclusive?

        • 1. Re: How to add one filter based on three (or more) columns
          Mark Holtz

          It's a bit "hacky" but the best way I've found to "filter multiple columns at once" is to build a "Combined Field" of all the columns you want to "contribute" to the filter field, (I am old-school and always build a calculated field using concatenation.

           

          [FilterField] calculation:

          [Field 1] + '-' + [Field 2] + '-' + STR([Field 3]).

           

          As long as your fields aren't numeric, the + operator functions to perform a concatenation. IF you have numeric fields, wrap in a STR() function.

           

          You can expose a multi-select that can be ugly, but you can also just employ that field as a wildcard quick filter.

          The user can just type in "Yes" and see data for all records that have "Yes" present in any of the columns.

          • 2. Re: How to add one filter based on three (or more) columns
            Joe Oppelt

            Can you pivot those [Person X] columns into one column?

             

            You could then have a simple filter where your user can select as many or as few Persons as he wants.

             

            That's not the end of the solution though.  Standard filters in Tableau do "OR" operations.  If you want only those rows where ALL the selected people used the station, you could create an additional filter that only selects stations that all the selected Persons used.  There are ways to do that, and it

            can get a little complicated, but before going into all that, first find out if you can pivot your columns into one column (either using Tableau's PIVOT feature if the data source allows it, or do it in the creation of your data source if Tableau can't pivot your type of source.)

            1 of 1 people found this helpful
            • 3. Re: How to add one filter based on three (or more) columns
              Jim Dehner

              Hi Robert

              Just a question - your created a table by putting People in separate columns - did you consider creating  a file with person / station and joined the 2 tables you would have a table with a dimension for Person and another for Station which could be filtered with quick filters

              Jim

              If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution.  Thank you.