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.
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]
)
)
)
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