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 August 31st. Request your voucher.

Reply
DavidC2020
Frequent Visitor

Calculating a measure based on finding text in a column

Hi,

 

I'm looking for some advice on how I can create a measure that counts the number of customers that do not have a specific event recorded against them.  An example of this is:

 

  • I have a Customers table
  • I have a Sales Fact table joined to the Customers (I do a DISTINCT on Customer Key to calculate the number of customers)
  • I have a Customer Note table connected to the Customer table

I would like to create a calculation which searches for specific text in the Customer Notes table and then filters the Customer Count measure to include Customers that don't have the search string in a Customer Note.

 

I've tried doing it the other way round first, calcualting the customer count that does have a specific text in a note, but I'm not having much luck:

 

Missing Fee Note =
CALCULATE(
[Customer Count],
FILTER ( Customer, CONTAINSSTRING ( 'Customer Note'[Note Text], "search text" ) )

 

I get an error above which says that it can't determine a single value.  Any help or pointers would be appreicated.

 

Thanks

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@DavidC2020 , make sure Customer Count is a measure

Try like example

 

CALCULATE(
count(Sales[Customer ID]) ,
FILTER ( Customer, not CONTAINSSTRING ( 'Customer Note'[Note Text], "search text" ) ) //added not , remove as per need

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
v-yinliw-msft
Community Support
Community Support

Hi @DavidC2020 ,

 

You can try the following methods.

 

Here's my test table:

 

Customer Note Table:

vyinliwmsft_0-1663133120996.png

 

 

Customer Table:

vyinliwmsft_1-1663133121001.png

 

 

Sales Fact Table:

vyinliwmsft_2-1663133121003.png

 

 

Measure:

 

Missing Fee Note =

CALCULATE (

    [Customer Count],

    FILTER (

        ALL ( 'Customer Note' ),

        CONTAINSSTRING ( 'Customer Note'[Note Text], "fail" )

    )

)

vyinliwmsft_3-1663133121006.png

 

 

In your code, the first argument to the filter function should probably be used Customer Note.

 

Missing Fee Note =
CALCULATE(
[Customer Count],
FILTER ( Customer, CONTAINSSTRING ( 'Customer Note'[Note Text], "search text" ) )

 

Is this the result you expect?

 

Best Regards,

Community Support Team _Yinliw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you for the example.  I was looking for instances where the text was not contained within the string.

amitchandak
Super User
Super User

@DavidC2020 , make sure Customer Count is a measure

Try like example

 

CALCULATE(
count(Sales[Customer ID]) ,
FILTER ( Customer, not CONTAINSSTRING ( 'Customer Note'[Note Text], "search text" ) ) //added not , remove as per need

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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