3 Replies Latest reply on May 17, 2018 12:20 PM by Eric Hammond

    How to implement logic

    Tulu Sahoo

      Hi All,

       

      We are facing one challenge while implementing few logics in Tableau. Below is the requirement details.

       

      I have three columns:

       

      call_key    source_cd    DW_flag

      ABC          A0001           DW

      ABC          A0002           DW

      ABC          A0003           Non-DW

      XYZ          A0004            Non-DW

       

      Expected output:

       

      DW_flag    count distinct(call_key)

      DW            1

      Non-DW     1

       

       

      Instead of getting the above o/p I am getting below o/p:

       

      DW_flag    count distinct(call_key)

      DW            1

      Non-DW     2

       

       

      For Non-DW I do not want to count      ABC          A0003           Non-DW because ABC call_key already count under DW.

       

      Please let me know if have any solution. Thanks

        • 1. Re: How to implement logic
          Eric Hammond

          Hi Tulu,

          Create a level of detail calculation that identifies only one DW-flag per call_key:  {FIXED [Call_key]: MIN(DW_Flag)]}.  Then put  this calculation on rows and add a distinct count of call_key to the text tile on the marks shelf. 

           

          The example below is from superstore, counting distinct customers per category - but not counting a customer under office supplies if they have already been counted as a furniture customer, etc.

          • 2. Re: How to implement logic
            Tulu Sahoo

            Hi Eric,

             

            I have millions of call_key that's why your logic giving me time out error. Please suggest any alternative.

            • 3. Re: How to implement logic
              Eric Hammond

              Hi Tulu,

               

              The requirement to count a call_key under non-DW only if it wasn't counted under DW appears to require calculations that cause lower performance.  Here is another approach that avoids the LOD calculation, but I don't have a large-enough data set to determine whether this is more efficient or less efficient than the LOD approach:

               

              Create a set of call_keys that have a minimum DW_Flag of "DW" (Right-click on call_key, create, set, condition tab, by field, DW_Flag, minimum, =, DW, OK).  Then place the set on the Rows shelf and place a distinct count of call_keys on the text tile on the marks shelf.  The result will show counts for "in" and "out", so for a better label place MIN(DW_Flag) on the Rows shelf, then right-click on the SET pill on the Rows shelf and un-check "show header".  If there are more than two values for DW_Flag then it will be necessary to create more sets.  The example below arrives at the same result as the previous example but uses sets instead of LOD.