Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
sc27
Frequent Visitor

Help with count of values based on individual values within a string

I am looking for a way to search a string for a specific name and count the number of accounts if there is a match 

Account NameTeam Group
AppleTim, Bill, Mike
MicrosoftTim, Steve, Allen
IBMRich, Allen, Tim
GoogleSally, Rich

 

Using the above I then leverage a separate list of non-concatenated Team Members to find out "how many Accounts does person X belong to?" Essentially I want to take the Team Member list below, search for each name within Team Member Group (I need this to be a variable; I cannot hard code the names as my list is much longer than this and can potentially change in the future) and then count the number of Accounts for where that person's name appears

 

My result would be 

Team MemberCount of Accounts
Bill1
Allen2
Rich2
Steve1
Mike1
Sally1
Tim3
5 REPLIES 5
Anonymous
Not applicable

This is not how you do it in PBI. The first table should be processed in Power Query, so that the associations are atomic, meaning each row should contain only one Account Name and one Team Member. It'll be a bridge table between Account Names and Team Members. Once you have this, it'll be dead easy to calculate what you want in DAX because it'll just be DISTINCTCOUNT( Bridge[Account Name] ).

Hmm, so the problem I have is that I am leveraging a data model. So I don't think I can use Power Query (please correct me if I am wrong here)

Anonymous
Not applicable

Well, if you've got a model that stores data like you've shown... it means the model is suboptimal. But can't you leverage a composite model? I bet you could...

I'd have to check, but my model is pretty locked down (purposely)

Anonymous
Not applicable

All you need is a query against your current model to get the first table and then using PQ to break it down into atoms just like I said above. Of course, you could work with the table above without atomizing it... but that could produce slow DAX. IF you want to go this route, then you could make use of the SEARCH function (https://dax.guide/search) in DAX. I strongly advise against it but it's up to you...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.