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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Count if contains part of text

Hi all!

 

I wonder if is there any function in DAX if I can count how many cells in a column contain a certain part of text.

 

Imagine tha I have a list of names and I want to count how many names contains the letter "a" for example. 

 

In excel we can do it by just puting "*" like this: countif(table[names];"*a*")

 

Right now I am using an auxiliar column to do it in my excel file, but I would like to do it without that auxiliar column.

 

I've also used the function search in power bi in a column, but I am really looking for a measure that can give me this result

 

Thank you so much 

 

Best regards

1 ACCEPTED SOLUTION
Floriankx
Solution Sage
Solution Sage

Pleae try this:

Countif:=CALCULATE(
COUNTROWS(Table);
SEARCH("a";Table[names];;0))

View solution in original post

8 REPLIES 8
Floriankx
Solution Sage
Solution Sage

Pleae try this:

Countif:=CALCULATE(
COUNTROWS(Table);
SEARCH("a";Table[names];;0))

Anonymous
Not applicable

I tried this formula out but it did not accept the semicolon, only commas. Do comma's work as well?

Anonymous
Not applicable

Another question, imagine now that I have another column with values and I want to sum all the values that whose name has the letter "a".

 

How would I change the formula that you gave me?

 

Thanks in advance

It should work if you build two measures and simply add them.

Anonymous
Not applicable

Sorry, but I didn't get it.  Imagine this example the final result would be 90 (sum of aanthony adam and agatha). 

 

namesvalues
anthony40
adam30
phill50
john30
agatha20


What do you mean by adding two measure? One would be the countrows and the other one the value of each row? 

But how would I do it?

Hello,

 

you just have to exchange the expression in your CALCULATE statement.

 

Sumif:=CALCULATE(
SUM(Name_search[values]);
SEARCH("a";Name_search[names];;0))

Hello,

 

I'm using this solution. I want to count 3 different textstrings in a colum.

 

I get an error cause of circular dependency when I write the function for the second string a want to count. 

Anonymous
Not applicable

Great, it works perfectly!

 

Thank you so much

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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