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.
OK
Screen shot one is using the Measure Count Referal Text 2 using your Dax code, and the table displaying the data.
and screen shot two is using the Measure Count Referal Text, which uses the Dax code I borrowed from youtube, which is a bit closer, but its only counting the strings when they appear on their own in a cell, not when in a long list of other strings.
Hope that's viewable - if not i'll enlarge them.
Thanks!
Adam
- BINewbie13 years ago
Helper II
Thanks Tamerj1,
That seems to be working fine now.
There's was a relationship between the tables and turning it off seems to have done the trick.
I also now know that there's isn't a 10th code for other - suspect the free text for other is kept somewhere else in the system.
Many thanks for all you work - its really appreciated!,
Adam
- BINewbie13 years ago
Helper II
Sorry here's a third screen shot with the fields atually as you wrote the code. I swapped them around just to check. But it made no difference.
- tamerj13 years ago
Community Champion
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.