Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

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 returni...
  • rsbin's avatar
    2 years ago

    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,