Solved

Count of Words in A String Using Custom Properties

  • 17 February 2021
  • 1 reply
  • 45 views

There is a search event search_query_entered in which a property search_term tracks what the user entered. I want to count the number of words that people enter. For this I tried using custom properties.

Is there any function that allows me to count the number of words in a string? If not, some combination of functions that would enable the same end-effect?

icon

Best answer by aaron 14 October 2021, 16:02

View original

1 reply

Badge +4

You should be able to get a word count by using the SPLIT() and LEN() functions. SPLIT splits a string into a list by a given character, and LEN() returns the length of a string or the length of a list. 

So, the combination would be something like this: LEN(SPLIT(your_property, “ “))

This splits a string on spaces to divide into a list of words, then counts the length of the list. 

Reply