Search code examples
if-statementgoogle-sheetslambdaduplicatestextjoin

How to I remove duplicate words when using =TEXTJOIN() function in google sheets or excel


I am trying to find a function that I can use that will eliminate duplicate wording when i join two cells together. I will attach a picture to show you what my ideal return is.

Ideal Return

For the Row 1&2 column, this is the function I used

=textjoin(":",True,A2,B2))

but i would like to find a function that will return me the Ideal Return instead. I am not looking to use the find and replace feature, as I would like to document each step I made, so a function would be best.


Solution

  • What about this one?

    =IF(EQ(A2;B2);A2;TEXTJOIN(":";true;A2;B2))
    

    nothing fancy though, if you want the fancy one, the answer with flatten from Harun24hr is better.

    But it is easy in what it does, if the cells are the same, then take the first cell, otherwise, concat the results.

    enter image description here