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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Anonymous
Not applicable

counting text values from a column

Dear community,


I am looking for a solution to count the amount of a certain text value occurs in a column. This sounds super simple, however I tried multiple formulas and my measure keeps returning blank. these formulas i tried and didn't work:

 

=DISTINCTCOUNT([Why did the employee decide to leave], "Job/Role") // not working


CALCULATE
(COUNTROWS('Exit interviews'),
'Exit interviews'
[Why did the employee decide to leave] = " Job/Role ") // not working

 

I have a dataset containing information on exit interviews. For some questions, participants can fill out multiple answers which results in one or multiple text strings in one column, delimited by " ; ".  For all the leaving reasons in that column, I want to count them to be able to display them in a graph. Here is what the column looks like:

RobinwDNV_0-1695736569776.png

 

I hope someone can tell me how to do this, or what i was doing wrong!

 

many thanks in advance 🙂

1 ACCEPTED SOLUTION
rsbin
Super User
Super User

@Anonymous .

First thing is you want to use COUNTA (used to Count Text Values) not DISTINCTCOUNT.  The way you are using DistinctCount will always give a 1.

Next, in your Filter context, it is looking for an exact string.  Your text value contains a semi-colon and hence PBI is saying it is not a match.  To account for this, use CONTAINSSTRING:

Containsstring = CALCULATE( COUNTA( ExitInterviews[Reason] ),
                     FILTER( ExitInterviews, CONTAINSSTRING( ExitInterviews[Reason], "Job/Role" )))

The other thing you may want to consider is using Power Query to split your Columns by Delimiter. Use the advanced functions to "Split into Rows".  Then you get all your Reasons individually by Row.

Hope this helps.

Regards,

View solution in original post

2 REPLIES 2
rsbin
Super User
Super User

@Anonymous .

First thing is you want to use COUNTA (used to Count Text Values) not DISTINCTCOUNT.  The way you are using DistinctCount will always give a 1.

Next, in your Filter context, it is looking for an exact string.  Your text value contains a semi-colon and hence PBI is saying it is not a match.  To account for this, use CONTAINSSTRING:

Containsstring = CALCULATE( COUNTA( ExitInterviews[Reason] ),
                     FILTER( ExitInterviews, CONTAINSSTRING( ExitInterviews[Reason], "Job/Role" )))

The other thing you may want to consider is using Power Query to split your Columns by Delimiter. Use the advanced functions to "Split into Rows".  Then you get all your Reasons individually by Row.

Hope this helps.

Regards,

Anonymous
Not applicable

It worked, thank you for the explanation! 🙂

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Power BI Header Change

Power BI Header Update

Read about the exciting updates for the Power BI forum.

Top Solution Authors