Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to display value if value is unique or duplicate in a column using an arrayformula Google sheets

I have a formula that returns either Unique or Duplicate depending on whether there already exists another value in the same column.

The formula =IF(COUNTIF($A$2:$A2,A2)=1, "Unique", "Duplicate") in B2

Example:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

  A      B
Peter | Unique
James | Unique
Peter | Duplicate
Anne  | Unique
James | Duplicate

The formula works as it should but I am looking for an alternative formula that works with arrayformula()

The reason is because my data is dynamic which means the ranges change time and time again. It’s not possible to manually drag the current formula each time the ranges change so an arrayformula for this would be very welcome.

>Solution :

Use this to be able to specify the range in this case A2:A once in LAMBDA() call.

=ARRAYFORMULA(
 LAMBDA(r   ,IF(r="",,IF(XMATCH(r,r,0,1)=SEQUENCE(ROWS(r))<>TRUE,
       "Duplicate","Unique")))
       (A2:A))

enter image description here

Used formulas help
ARRAYFORMULALAMBDAIFSEQUENCEROWSUNIQUE

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading