Search code examples
google-apps-scriptgoogle-sheetssplitconditional-formatting

How to Split the value and find the longest text string in google sheet


I have a column in google sheet in which each cell contains this type of text

manager, finance manager
accountant
accountant, chief accountant
manager, auditor, other, finance manager
accountant

I want to find the longest text like below and show that text into new cell

finance manager
accountant
chief accountant
finance manager
accountant

I used split function to split the text and find function but finding character or number of character is working but i am unable to understand how i will get whole longest word

Kindly help me.


Solution

  • An alternative would be to use

    =FILTER(TRIM(SPLIT(A1, ",")), LEN(SPLIT(A1, ",")) = MAX(LEN(SPLIT(A1, ","))))
    

    and fill down as far as needed.