First, in order to turn this calculation into a measure, simply replace the first line of the CountOfItems calculation with the following:
VAR __List = MAX('R03_Table'[List])
Second, this recipe can work with any delimiter between values. Simply replace the middle parameter of the SUBSTITUTE function with the delimiter used within your list.
Third, you may run into a situation where you have a multi-character delimiter such as the following table, R03_Table1, where the delimiter is a double quote followed by a comma followed by a space followed by another double quote:
List |
"One, Two" |
"One, Two", "One, Two" |
"One, Two", "One, Two", "One Two Three" |
"One, Two", "One, Two", "One Two Three", "One, Two, Three" |
In this circumstance, the same recipe can be used with minor modifications as follows:
CountOfItems =
VAR __List = 'R03_Table1'[List]
VAR __Length = LEN( __List )
VAR __Delimiter = """, """
VAR __LenDelimiter = LEN(__Delimiter)
VAR __Length2 = LEN( SUBSTITUTE( __List , __Delimiter , "" ) )
VAR __Count = DIVIDE(__Length - __Length2 , __LenDelimiter, 1)
RETURN
__Count + 1