How to count words in a field

Hello,
I have a list of names separated by Break element (<br> in html format).
I need to output the count of this list but I can’t find a way to count them
Example:
Field returned - “John Smith <br> Peter Johnson <br> Mark Anderson” (converted from html to plain format)
Outcome needed - 2

Basically, do the count of how many names(-1) are in 1 field.
Is this possible to do with MDX?
I’ve tried with Val, ExtractString and with Replace but I don’t get the desired result

Appreciate any help on this.

Thank you
Marcello

Hi, Marcello

The solution to this use case is to count the delimiter <br> occurrences in the string. In MDX, that can be done using Len and Replace functions. If the original string comes from a measure “some string” the formula is the following:

(Len([Measures].[some string])
  - Len(Replace([Measures].[some string],"<br>","")))
  /Len("<br>")

Kindly,
Janis, eazyBI support