1 Reply Latest reply on Sep 3, 2018 7:12 PM by lei.chen.0

    Filters and self-join-like filters on a datasource

    Daniel Vacca

      Hello community,

       

      I have been trying to implement the following in Tableau but have not been able to. I hope you can give me a hand.

       

      I have a table A with three sets of columns: Cols1, Cols2 and Cols3. My goal is to display some data (and calculated data) from a filtered version of A. There are two phases of filtering.

      In the first one, filters are applied on Cols2. The values in these filters are defined by the user from the dashboard; this means that multiple values can be selected for each column.

      The second one is trickier. Let B be a subset of (the result of the previous filtering of) A filtered on a column in Cols3; the values of this filter are independent from user's selection. From A we will keep only the rows such that there exists at least one row in B with the same values along Cols1; that is, we will keep the rows in A that match with some row in B on the columns Cols1.

      In particular, all the rows in B will be in the output.

       

      Let me give you an example. Consider A to be

       

      Cols1

      Cols2

      Cols3

      1

      a

      !

      2

      b

      #

      2

      a

      $

      2

      c

      ()

      3b%
      5b?

       

      And B to be (without any first-phase-filters on A):

       

      Cols1

      Cols2

      Cols3

      1

      a

      !

      2

      b

      #

      2

      c

      ()

       

      Without any filters, the result should be

       

      Cols1

      Cols2

      Cols3

      1

      a

      !

      2

      b

      #

      2

      a

      $

      2

      c

      ()

       

      If the user selects Cols2=a, the result should be

       

      Cols1

      Cols2

      Cols3

      1

      a

      !

       

      If the user selects Cols2=b, the result should be

       

      Cols1

      Cols2

      Cols3

      2

      b

      #

       

      If the user selects Cols2=c, the result should be

       

      Cols1

      Cols2

      Cols3

      2

      c

      ()

       

       

      The way I modeled it is to create a dataset B by copying A and applying datasource filters on Cols3, and then blend A and B on Cols2. The problem is now to apply the filters on Cols1.

      Note that it is not enough to apply the filters only on A or B. Filtering only on A would mess the result with Cols2=a, and filtering only on B would mess the result with Cols2=b. I have an already posted discussion on this approach here.

       

      Thanks.