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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
MarkHansen
Frequent Visitor

Counting how many times a word is in a column

I've looked at many similar suggested strings but since I'm new to Powr BI and DAX, I'm having a hard time translating the solutions into what I need.

 

I have a columns labled "Emotional Depression" and in that column will be "Depression" if the client checked a box saying they were having a hard time with depression.  So each row in that column will either be blank, or have the word "Depression".  (A little strange data set I know, but I used the data to assist with writing a note.)

 

Eventually I would like to make a pie chart with the numbers because I have four Emotional columns but I can't even get out of the gate with getting a usable number.

 

I assume I need to create a measure, but can't get the DAX correct (if that's even the correct way to go).

 

Thanks for any insight.

 

1 ACCEPTED SOLUTION
Dog
Responsive Resident
Responsive Resident

you could also (as just realised that the column would only contain this word or nothing) 

 

ContainsDepression=
IF([Emotional Depression] = "Depression",1, 0)

View solution in original post

5 REPLIES 5
sokatenaj
Advocate II
Advocate II

You can create a measure using this formula:

 

# Depression = CALCULATE(COUNTAX('TableName','TableName'[Emotional Depression]),'TableName'[Emotional Depression]="Depression")

 

Everytime you update your feed, it will update the count. 

 

Edit: Forgot the apostrophes. 

Thanks, I'll give that one a try too1

MarkHansen
Frequent Visitor

Thanks for you quick and accurate reply Dog.  I appreciage the help!!

 

Mark

Dog
Responsive Resident
Responsive Resident

Hi @MarkHansen

 

I suppose an easy way through DAX is to create a calculate column first off which checks if it can find the word depression in the column. I use "SEARCH" because it's not case sensitive. 

 

ContainsDepression=
var IsFound = SEARCH("Depression", [Emotional Depression], ,0)

RETURN
IF(IsFound = 0, 0, 1)

 

you can then create a new measure that simply counts up these values. 

DepressionRows:=Calculate(sum([ContainsDepression]))

 

not sure if this helps or not? 

 

Dog

 

 

Dog
Responsive Resident
Responsive Resident

you could also (as just realised that the column would only contain this word or nothing) 

 

ContainsDepression=
IF([Emotional Depression] = "Depression",1, 0)

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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