Skip to main content

Hi Community

Tableau Prep - identify the first duplicate item

 

I have some items as shown above which is duplicate and I would like to count the first occurrence of those duplicate item only. Is it possible to label the first item with 1 and the remaining item with 0 in Tableau Prep?

 

Any help will be appreciated.

 

Thank you.

1 answer
  1. Mar 26, 2020, 3:02 PM

    Hi Kenny,

     

    If you are using 2020.1 or later, you can use the Row_Number() function.  In your case, you'll want to specify the calculation as something like:

     

    { PARTITION [Target Location],[Ref #] : {  ORDERBY [Target Location] : ROW_NUMBER()}}

     

    That will cause the rows numbers to restart for every new Locaiton and Ref #, with results like this:

     

    Hi Kenny, If you are using 2020.1 or later, you can use the Row_Number() function.

     

    If you want to replace anything > 1 with 0, that's another easy calculation:

     

    IF [Row Number] > 1 THEN 0 ELSE 1 END

     

    Hope that helps!

    Joshua

0/9000