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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
matthesc
New Member

Countif Contains Based on a List

Hello,

 

I am trying to create a measure that will count the number of instances a particular phrase appears in a column based on a unique ID. Example, I have a list of customers that has a column titled 'Pets' and in this columns the data is structured as '{Cat},{Dog},{Lizard},{Bird}' for customer 1, and customer 2 has '{Cat},{Fish}', customer 3 has '{Dog},{Bird}'. Based on the Pets column I would like to know the count of customers who own a Cat. Im gussing the function would be similar to the Countif function in excel?

 

Thanks

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @matthesc,

 

You can add a custom column and use 'Text.Split' and 'List.Contains' function to check if it contains specific items.

 

Sample formula:

#"Added Custom" = Table.AddColumn(#"Changed Type", "Contains", each List.Contains(Text.Split([Pet],","),"{Cat}"))

 

You can use below function to replace bold part of formula to change the check method or check item amount.

 

Reference link:

Function Description
List.Contains Returns true if a value is found in a list.
List.ContainsAll Returns true if all items in values are found in a list.
List.ContainsAny Returns true if any item in values is found in a list.
Text.Split Returns a list containing parts of a text value that are delimited by a separator text value.

 

1.PNG2.PNG

 

Regards,

Xiaoxin Sheng

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @matthesc,

 

You can add a custom column and use 'Text.Split' and 'List.Contains' function to check if it contains specific items.

 

Sample formula:

#"Added Custom" = Table.AddColumn(#"Changed Type", "Contains", each List.Contains(Text.Split([Pet],","),"{Cat}"))

 

You can use below function to replace bold part of formula to change the check method or check item amount.

 

Reference link:

Function Description
List.Contains Returns true if a value is found in a list.
List.ContainsAll Returns true if all items in values are found in a list.
List.ContainsAny Returns true if any item in values is found in a list.
Text.Split Returns a list containing parts of a text value that are delimited by a separator text value.

 

1.PNG2.PNG

 

Regards,

Xiaoxin Sheng

Interkoubess
Solution Sage
Solution Sage

Hi,

 

Suppose your client column is named Customer, cretae this measure CustomerNumber=Distinctcount([Customers]) and put in your report for example the pets colums in row and then your measure.

 

Thx

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Kudoed Authors