Forum Discussion
Counting comma delimited text strings
- 3 years ago
BINewbie1
Looking at this screenshot I instantly realized my mistake. We need to filter the complete table as the VALUES of the column will return only distinct values and duplicates won't be counted.However, in the example that you have provided earlier, the first code would have produced 3 not 2. I will create a sample file to double check. For now please try
Count Referal Text = COUNTROWS ( FILTER ( CROSSJOIN ( pre_referral, VALUES ( 'Lookup BBBC_referalreasonquestions_health'[Code] ) ), CONTAINSSTRING ( pre_referral[bbbc_referralreasonquestions_health], 'Lookup BBBC_referalreasonquestions_health'[Code] ) ) )*UPDATE
Attached is the sample file
Also make sure there is no relationship between the two tables. Some times it is automatically created without you even noticing.
Hi tamerj1,
Thanks.
So in this field say there are 5 rows, which look like:
441690000, 441690001, 441690004, 441690006
441690001, 441690003, 441690004, 441690006
441690009 = 2
Watching a youtube video I've come up with the following Measure, which seems to do something but maybe is under reporting, and seems to have a large number of null/blank fields, which maybe the data, or maybe the Measure.
Adam
- tamerj13 years ago
Community Champion
Assuming pre_referral[bbbc_referralreasonquestions_health] is the column that contains the comma delimit strings and 'Lookup BBBC_referalreasonquestions_health'[Code] is column from the disconnected table tyat contains the distinct unique values of the strings (also text data type not integer) which is the column placed in the table visual, then please try
Count Referal Text =
COUNTROWS (
FILTER (
CROSSJOIN (
VALUES ( pre_referral[bbbc_referralreasonquestions_health] ),
VALUES ( 'Lookup BBBC_referalreasonquestions_health'[Code] )
),
CONTAINSSTRING (
pre_referral[bbbc_referralreasonquestions_health],
'Lookup BBBC_referalreasonquestions_health'[Code]
)
)
)- BINewbie13 years ago
Helper II
Thanks for offering this.
It doesn't work i'm afraid, just a 1 value for each reason, and 144 for 151 blanks (no idea where that's coming from). Maybe its counting distictvalues?
The string value in the lookup table was actually set to an integer, but I changed it to text, but seems to make no difference to either measure.
Thanks again.
Adam