cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Advocate II
Advocate II

Count the number times a specific character appears in a text field

I have a multi-line text field where the data is delimited by commas.  The field can contain from 1-32 items.  Example: Chicago, Boston, Seattle.  I need to determine the number items in the field (in the example it is 3). 

 

I tried using split with a variable counter:   split(variables('Locations'),',')[variables('varIndex')]  This split sits in a DoUntil loop that increments varIndex by one.  However, when the index count exceeds the number of items, I get an error of 'out of bounds array index'.

 

How can I get a count of the commas or the items?  If I know the count beforehand, I can set the DoUntil to stop before it tries the split and throw the error.

 

Thanks!

 

1 ACCEPTED SOLUTION

Accepted Solutions

Have you tried the following to get the length of your array?
length(split(variables('Locations'),','))

View solution in original post

2 REPLIES 2

Have you tried the following to get the length of your array?
length(split(variables('Locations'),','))

View solution in original post

Pieter,

That worked perfectly.  Thank you very much!!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Top Solution Authors
Top Kudoed Authors
Users online (11,100)