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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

I need a function that search the value provided and count it

Hi all,

I'm trying to count the number of row that a value occures in a column.

The column is set like that : 

x+y+z

z+b+t

h+x+y+o

a+z+e+r

I need to get the number of time that one of these letters (Y for exemple) has been repeated.

I tried with COUNTA, COUNTX, COUNTAX and the result isn't correct, it always return the total number of rows.

I need a function that search the value provided and count it.

For exemple i need to know how many Y i have,  it would return 2.

ps : I used this function in excel and it works : =COUNTIF('table1M2:M1794,"*Value*")

Thanks in advance

2 ACCEPTED SOLUTIONS
PaulDBrown
Community Champion
Community Champion

@Anonymous 

 

You can use the function CONTAINSSTRING.

For example, to count number of rows which contain "y", use:

Count Y = CALCULATE(COUNTROWS(Data);
            FILTER(Data;
                CONTAINSSTRING(Data[String]; "y")))

And you get:count y.JPG

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

Anonymous
Not applicable

Hi 

It was a syntax error,

I replaced ";" by "," and it worked.

Thankyou very much for your help

View solution in original post

8 REPLIES 8
PaulDBrown
Community Champion
Community Champion

@Anonymous 

 

You can use the function CONTAINSSTRING.

For example, to count number of rows which contain "y", use:

Count Y = CALCULATE(COUNTROWS(Data);
            FILTER(Data;
                CONTAINSSTRING(Data[String]; "y")))

And you get:count y.JPG

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Anonymous
Not applicable

Hi Paul,

Thank you for quick response.

I get this error message when trying to do it : Unexpected expression FILTER, Unexpected expression CONTAINSSTRING

Do you think that i need to install a package or something?

Regards,

 

 

 @Anonymous 

 

What version of Power BI Desktop are you using? 

It should work if you have the latest version installed.

measure.JPG

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Anonymous
Not applicable

I use this version : 2.76.5682.0

Is it the latest version?

@Anonymous 

 

Latest version is: 2.76.5678.782 64-bit (December 2019)

 

It is important to use the latest versions for a number of reasons, including the fact that functions are added to DAX periodically. (You may be using a version which does not have CONSTAINSSTRING included).

I cannot recall when the function was added, so I can't pinpoint the exact version which started including this function.

 

EDIT: download the latest version from the link on this page:

https://powerbi.microsoft.com/en-us/desktop/ 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Anonymous
Not applicable

I've installed the new version and here's the error message that I get

It tells that the syntaxe is incorrect : Untitled - Power BI Desktop.jpg

Do you think it's related to the fact that i'm using free power BI?

Do i need a pro license?

Regards,

Anonymous
Not applicable

Hi 

It was a syntax error,

I replaced ";" by "," and it worked.

Thankyou very much for your help

@Anonymous 

Oh, sorry about that. My version pf Power BI uses ";" as a separator instead of a ",". I should have warned you ealier.

I'm glad you worked it out,

 

PS. Can you please mark the post which Solved your question as the solution? It will help others looking for similar solutions.Thanks.





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors