Counting the occurrence of a certain character in string

Hello there,

I was wondering if there is a way to count the occurrence of a certain character in a string.

 

Specifically, I have a column that contains the gender information (M or F) of each data entry. 

All of the data entries are grouped according to a unique key, and while grouping, the gender column is collapsed with a comma between each entry belonging to that group.

Now I need to count the number of M's and F's for each group.

 

Could you please advise if this can be done.

Thank you in advance. 

 

Best,

Roxie

Comments

  • jaeW_at_Onyx
    jaeW_at_Onyx Budapest / Portland, OR 🟤

    yes.

    calculate the length of your string.

    then subtract the length of your string if you replace the search character with a blank.

    ex. length('mf_string') - length(replace( 'mf_string', 'M', ''))