Forum Discussion
mithunishad
2 years agoNew Member
Word count from a sentence
I am trying to find the number of times particular texts appear in a description. For example if the description is " faulty item LAV-L3,LAV-L3F,LAV-L3R found". I want to count how many times "LAV-L3...
Sahir_Maharaj
Super User
2 years agoHello mithunishad,
Can you please try this approach:
ExactMatchCount =
VAR SearchText = "LAV-L3"
VAR SearchTextLength = LEN(SearchText)
VAR Description = [YourDescriptionColumn]
VAR DescriptionLength = LEN(Description)
VAR CleanedDescription = SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(Description, ",", " "), ".", " "), "-", " ")
VAR TextParts = TRIM(CLEAN(CleanedDescription))
VAR WordCount =
COUNTROWS(
FILTER(
GENERATESERIES(1, DescriptionLength - SearchTextLength + 1, 1),
MID(CleanedDescription & " ", [Value], SearchTextLength) = SearchText
&& MID(CleanedDescription & " ", [Value] + SearchTextLength, 1) IN {" ", "", ","}
)
)
RETURN
WordCount