Search code examples
regexgoogle-sheetsconcatenationgoogle-sheets-formulaarray-formulas

How to merge strings and skip duplicates?


Let's say you have a product information sheet that includes columns like "Material", "Finish", and "Color":

Glass   Aqua            Blue
Glass   Clear           Clear
Glass   Clear           Brass
Brass   Polished Brass  Brass

And you want to concatenate them, but without duplicating, so the end result will be:

Glass, Aqua, Blue
Glass, Clear
Glass, Clear, Brass
Brass

(So it skips the 2nd Clear in Line 2, and the 2 cells containing "Brass" in Line 4.)

Any solutions, or even suggestions as to which functions to play with, would be appreciated.


Solution

  • try:

    =ARRAYFORMULA(IFNA(REGEXEXTRACT(
     IFNA(REGEXEXTRACT(B:B, A:A), A:A&", "&B:B), C:C), 
     IFNA(REGEXEXTRACT(B:B, A:A), A:A&", "&B:B)&", "&C:C))
    

    enter image description here