Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Context:
Table1 = 'Companies' (list of companies)
Table2 = 'Specialties' (list of areas of expertise of those companies)
Relationship = 1:M (one company has multiple specialties)
| Company_id | Company_name |
| 1 | Microsoft |
| 2 | |
| 3 | Amazon |
| Specialty_id | Specialty_name | Company_id |
| 1 | Cloud | 1 |
| 2 | Data | 1 |
| 3 | Database | 2 |
| 4 | System Architecture | 2 |
| 5 | Security | 2 |
I want to create a column in the table 'Companies' that counts the amount of specialties of that company containing one of many strings. In other words, the column 'Specialty_name' has to be filtered so that only the rows remain that contains one of the strings (not exact).
List of strings = {"Data", "Cloud", ...}
So the output should be:
| Company_id | Company_name | Count_Specialties |
| 1 | Microsoft | 2 |
| 2 | 1 | |
| 3 | Amazon | 0 |
As you see, the new column should also count "Database" even though that exact string is not in the list (only "Data").
So far, I managed to create a DAX but it's very long and inefficient:
Solved! Go to Solution.
Hi @Anonymous ,
You need to put all the conditions into the formula. There doesn't seem to be a simpler way.
Or you can put the conditions into a column. Then count the column.
Column = if(CONTAINSSTRING('specialties'[specialty_name ], "Cloud") || CONTAINSSTRING('specialties'[specialty_name ], "Data"),1,0)Measure = CALCULATE(COUNT(Specialties[Column])+0,FILTER(ALL('Table'),'Table'[Company_id ]=SELECTEDVALUE('Table'[Company_id ])))
If I have misunderstood your meaning, please provide your pbix file without privacy infromation and desired output.
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
You need to put all the conditions into the formula. There doesn't seem to be a simpler way.
Or you can put the conditions into a column. Then count the column.
Column = if(CONTAINSSTRING('specialties'[specialty_name ], "Cloud") || CONTAINSSTRING('specialties'[specialty_name ], "Data"),1,0)Measure = CALCULATE(COUNT(Specialties[Column])+0,FILTER(ALL('Table'),'Table'[Company_id ]=SELECTEDVALUE('Table'[Company_id ])))
If I have misunderstood your meaning, please provide your pbix file without privacy infromation and desired output.
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi:
You can do this via the data model by either a measure or a new table. Please see two tables (different ways of calculating the same result) and a measure doing the same thing. Please see link here:
https://drive.google.com/file/d/1EcZBdUDVUC0cOb3CSM1QdnblfbvZQzxL/view?usp=sharing
Hey, thanks a lot for your response!
Unfortunately don't think I was clear enough in the description. I have a big list of relevant Specialties on which I want to filter, but the amount of Specialties linked to the companies is much higher. So it's not enough to just count the specialties. I know the example I gave was misleading because all of the specialties needed to be counted.
I will edit the post, let me know if it still isn't clear!
Hopefully you can still help 🙂
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 20 | |
| 10 | |
| 9 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 34 | |
| 31 | |
| 20 | |
| 12 | |
| 11 |