Skip to main content

Hello Tableau Community,

 

I have a question on how I can remove duplicates.

 

This one was a bit advance for me where it involves 2 dimensions as opposed to 1 dimension. One Dimension value called Product Description will be the duplicate, but the other dimension, Status, will not. The Status will consist of the following Active, ATP DISPENSING ONLY, BACK UP OHARMACY ONLY, Compound Ingredient Only, DO NOT USE Enter as IV RX, Inactive, Profile Only, and Special Order.

 

I know how to remove duplicates by using a LOD expression where a DCount would be done on the Status > 1

{ FIXED [Product Description]: COUNTD([Status]) > 1  }

But this would set TRUE to all the Product Description where both duplicates would be omitted and I only want one to be omitted and keep the other. So that is when I came up with this concept:

{ FIXED [Product Description]: COUNTD([Status]) > 1  } AND [Status] <> "Active"

At that time, I was under the impression that there will always be a Status of "Active" in the Dupes and if so, this will always removes all the dupes with status not equal to "Active". I would place this LOD expression in the filter and set it for False:

Removing Duplicates 

 

But unfortunately, I realized that is not always the case. I did come across some dupes where Status doesn't always have the value of Active and my LOD expression would omit both and I do not want that:

imageSo I need to somehow identify the duplicates which I believe I have successfully achieve that part of it, but not to omit the first value of the dupe despite what the Status value is.

 

I tried attempting the following:

{ FIXED [Product Description]: COUNTD([Status]) > 1  } AND { FIXED [Product Description]: COUNTD([Status]) = 1  }

I figure this LOD expression would identify the duplicates in the Product Description and then setting DCount of Status equaling to 1 would keep the first value and omit the rest, but unfortunately that was not the case.

 

Any suggestion or help would be appreciated. Attached is a copy of the workbook. Thank you for taking the time reading this.

9 answers
  1. Dec 23, 2022, 2:29 AM

    I think there might be a simpler approach. I'm limited to Tableau Public right now, so I can't open the workbook.

     

    Create a hardcoded index of statues in priority order.

    Index Status

    Case [Status]

    When 'Active' Then 1

    When 'DO NOT USE...' Then 2

    ...

    When 'Inactive' Then 6

    END

     

    Find the lowest status for for each Product.

    Min Status Index

    {Fixed [Product Description] : Min( [Status Index] )}

    Then you can compare the status to the min status to get a Boolean.

    [Status Index] = [Min Status Index]

     

    Hope this helps!

    I'd be happy to do a mock up if you have further questions, as long as you publish your workbook to Tableau Public so that I can access it.

0/9000