Forum Discussion
DAX Count Filtering where a column contains text from another Table's Column
Hello I need to create a meassure that counts the items in a column filtering if the column contains a text from another table's column, I'll explain.
Table1:
| ID | Product |
| 1 | Apple, Banana, Orange |
| 2 | Apple |
| 4 | Banana |
| 5 | Orange |
| 6 | Banana, Orange |
| 7 | Apple, Grape |
| 8 | Grape |
| 9 | Banana, Orange, Grape |
| 10 | Orange, Grape |
Table2: (Fruits Catalog)
| Fruits |
| Apple |
| Banana |
| Orange |
| Grape |
What I need is for each Table2[Fruits] count the Table1[ID] when Table1[Product] contains Table2[Fruits].
Expected outcome:
| Apple | 3 |
| Banana | 4 |
| Orange | 5 |
| Grape | 4 |
Hope you can help me, I have tried with the contains and containsstring with no posisitve results.
Thank you
6 Replies
- AlB
Community Champion
Hi Anonymous
Try this:
1. Place Table2[Fruit] in the rows of a matrix visual
2. Create this measure and palce it in the visual
Measure = COUNTROWS ( FILTER ( Table1; CONTAINSSTRING ( Table1[Product]; SELECTEDVALUE ( Table2[Fruits] ) ) ) )Please mark the question solved when we get to the solution and consider kudoing if posts are helpful.
Cheers

- AnonymousNot applicable
Hello AlB I tried as you instructed but it is only showing the individual values, so it is not counting the fields where I have mixed fruits (cases..1, 6, 7, 9,10)
the output is showing:
Apple 1 Banana 1 Orange 1 Grape 1 - AlB
Community Champion
You sure you're doing it as described? I get exactly the results you show in your first post