cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
DTooley
Level: Powered On

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
Super User
Super User

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

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

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

Have you tried the following to get the length of your array?
length(split(variables('Locations'),','))
DTooley
Level: Powered On

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

Pieter,

That worked perfectly.  Thank you very much!!

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020

thirdimage

Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 282 members 3,274 guests
Please welcome our newest community members: