Skip to main content

In this excel sheet, you can see that we have considered unique as well as duplicate value.

There are three values consisting of id 11 as shown in the excel format. But on consideration of the following formula in excel =IF(A3=A2,"Duplicate","Unique"), I get 1 out of the 3 records as unique and the rest as duplicate. I need to formulate the following formula in tableau or tableau prep. Any idea on how it can be done? Please let me know about it.

 

Thanks

How to consider 1 unique value in duplicate values?

14 answers
  1. Mar 16, 2021, 11:24 PM

    I'm going to assume that the order doesn't matter so I'll just order by Country. In that case, create this calculated field:

     

    Row Number

    { PARTITION [ID] : { ORDERBY [ID] ASC, [Country] ASC: ROW_NUMBER()}}

     

    See https://help.tableau.com/current/prep/en-us/prep_calculations.htm for more details on how this works. That will give you data like this:

     

    I'm going to assume that the order doesn't matter so I'll just order by Country. 

    Essentially, it will number each row sequentially, starting over at each ID, and ordering by Country. We can now count each 1 as "Unique" and all other numbers as "Duplicate".

     

    Unique or Dupe

    IF [Row Number] = 1 THEN "Unique" ELSE "Duplicate" END

     

    End result:

     

    83 

    See attached packaged workflow.

0/9000