3 Replies Latest reply on Jun 21, 2018 10:07 AM by Joe Oppelt

    Applying two filters on one calculated field

    Niti Mishra

      Hi,

       

      My dataset has two columns named Domain, Domain_1 and Domain_2. The values in these columns as expected are not same. however, the possible values these columns can take are same.

       

      I have two calculated fields - Calc_1 that requires filtering on Domain_1 and Calc_2 that required filtering on Domain_2.

       

      I now have a new Calc field - Calc_3, which is (Calc_1 + Calc_2). However this simple sum will not be accurate because their filters are different.

       

      Is there a work around for this in tableau? I have tried creating a parameter but it did not work.

       

       

      Example data set

       

      ID Domain_1 Domain_2

      1   A                 C

      2   B                 A

      3   C                 B

      4   A                  B

      5   B                 A

        • 1. Re: Applying two filters on one calculated field
          Joe Oppelt

          I don't understand.

           

          What does "requires filtering on Domain_1" mean?

           

          A sample workbook would really help here.  then I can see the calcs and filters, etc.

          • 2. Re: Applying two filters on one calculated field
            Niti Mishra

            workbook attached.

            As you can see in the two sheets, the tables differ by Domain. I want to be able add 1st row of sheet 1 and 2nd row of sheet 2. So, the results must be  -

            A   B  C  D

            4   3   4   4

            I can add the count distinct X and Y values of the same domain (Sheet 3). However, as of now if I want to add the count distinct value of X based on Domain 1 and count distinct value of Y based on Domain 2 and show the sum based on Domain (1 or 2 since the values are same), is there a way to be able to do that?

             

            As you may have noted the value of B must be 3 and not 2.

            • 3. Re: Applying two filters on one calculated field
              Joe Oppelt

              (V 10.4 here),

               

              In the attached I made a second data source.  The excel file is a copy of what your data source was.  But then when I brought it into Tableau, I did a PIVOT on the two Domain columns.  That places both domains into one dimension, and we can do things much easier that way.


              The pivot creates two columns:  [Pivot field names] and [pivot field values].  (You can rename them.)

               

              Once I had it that way, I used LOD to gather the countd values you are looking for.  And now, on one sheet, you have both sets of data and you can move forward with whatever analysis you need to do.


              this will let you filter on "A", for instance, if that's something you needed to do.