cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

count frequency of specific character in a string

Firstly: this question probably sounds similar to this one.

But that query could not answer my question as far as I could tell. 

 

I have a table which uses a projectCode column to establish whether a given record is a parent, child or subchild. 

 

Parent entries are denoted as a number, eg 6. 

 

Child entries are denoted as a number, a comma and then another number. Eg 6,8. 

 

Subchild entries follow this theme, with 2 commas. Eg 6,8,3. 

 

It would be useful for me to use 'number of commas in projectCode' logic to establish whether a given item is a parent, child or subchild in powerapps, but I can't figure out how to do this. Ideas? Thanks!

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Super User
Super User

Re: count frequency of specific character in a string

@Anonymous 

My suggestion would be to use SPLIT to change the Text data into a single column table and then COUNTA the rows.

 

CountA(Split(TextInput1.Text,","))-1

 

It just so happens I responded to a similar question last night so the code was still available in my forum testing app.

https://powerusers.microsoft.com/t5/Building-Power-Apps-Formerly/Replacing-a-string-with-mutiple-commas-by-a-single-comma-using/m-p/407092#M119751

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

Anonymous
Not applicable

Re: count frequency of specific character in a string

Perfect-thank you!

View solution in original post

4 REPLIES 4
Highlighted
Super User
Super User

Re: count frequency of specific character in a string

@Anonymous 

My suggestion would be to use SPLIT to change the Text data into a single column table and then COUNTA the rows.

 

CountA(Split(TextInput1.Text,","))-1

 

It just so happens I responded to a similar question last night so the code was still available in my forum testing app.

https://powerusers.microsoft.com/t5/Building-Power-Apps-Formerly/Replacing-a-string-with-mutiple-commas-by-a-single-comma-using/m-p/407092#M119751

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

Anonymous
Not applicable

Re: count frequency of specific character in a string

Perfect-thank you!

View solution in original post

Highlighted
Super User
Super User

Re: count frequency of specific character in a string

@Anonymous 

No problem at all.  If my post solved your issue please mark it as the Solution to close the thread.

Highlighted
Anonymous
Not applicable

Re: count frequency of specific character in a string

Unfortunately I had to re-upload the (static excel) data this afternoon and now each 'split' function is presenting an 'invalid argument' error. I tried formatting all ID_numbers as text in excel but this did not solve the issue. And using text() to wrap the function like below simply meant that the split() function was ignored/not executed:

 

CountA(Split(Text(TextInput1.Text),","))-1

Also, entering '.text' at the end of textInput1 in your example did not make it a valid argument type. This is just a column of plain text values...do you know what's going on? Thanks. 

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (10,589)