Hello Community,
I have a situation where I need to count the number of words in a column. The words are separated by comma. I know using CountWords() we count the words in a string where they are separated by space. How can I do the same when they are separated by comma? Thank you in advance for your support. 😊
Solved! Go to Solution.
Here you go!
Use this expression: CountWords(REGEX_Replace([Field2], ",", " "))
were field 2 is your concat_type field. The regex replaces the commas by a space, making it possible for the countwords to do its magic!
Greetings,
Seb
Thanks Seb for the quick response. I tried with a similar solution like yours as shown below and it worked. But I was looking for function like CountWords() where I could provide the delimiter as an option.
My logic is as shown below and it worked. I was wondering why you used REGEX_Replace() instead regular Replace(). Do you have an explanation for that?
CountWords(Replace([Concat_Type], ',', ' '))
Hi @sreekanthac
Your replace expression does exactly the same as the stacked countwords/regex expression. The deliminator "comma" is provided in the REGEX_replace function as well between the quotations.
It doesn't matter in this case whether to use the replace or regex_replace function. You would want use the REGEX_replace function when you want to replace the comma on specific positions within a sentence only but keep some other commas (you could say, a harder replace).
Greetings,
Seb
Hi there,
I have a question. In this specific scenario from sreekanthac. How would it be possible to count each word which occurs in the column Concat_Type?
So that I would have a list like this
Thanks in Advance