cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MrAutomate
Helper III
Helper III

Parsing from Left to Right

Need some help in powerautomate flow.

 

I have a filter array (

split(body('Filter_array')[16], ': ')[1])
 

that returns this value:

6300 West Main St Midlothian VA 23112

 

I need some help getting the CITY (Midlothian for this record)

 

The I am using SPACE as a split delimiter, but that will be a problem if there are less spaces in some addresses.

 

Don't need state, and I am good on the ZIP : 

split(body('Filter_array')[16], 'VA')[1]
 
It would be work if a NEGATIVE @ worked liek this, but that is not correct :
split(body('Filter_array')[16], 'VA')[-1] does not return the index to the LEFT of 'VA', which if it did, would return the CITY.
 
I Am extracting each value using a Compose action.
Thanks for pointing me in the right direction.
1 ACCEPTED SOLUTION

Accepted Solutions
Mister_Shaik
Super User
Super User

Hi @MrAutomate ,

 

Why don't you try this,

 

split(split(body('Filter_array')[16],'VA')?[0],' ')?[sub(length(split(split(body('Filter_array')[16],'VA')?[0],' ')),2)]

 

In this, I'm getting the left part of "VA" and then using the length of array -2, I'm getting the city name.

 

Hope this helps 🙂


Kind Regards,
Shaik Sha
________________________________________________________________________

If I have answered your question, please mark the post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

3 REPLIES 3
Mister_Shaik
Super User
Super User

Hi @MrAutomate ,

 

Why don't you try this,

 

split(split(body('Filter_array')[16],'VA')?[0],' ')?[sub(length(split(split(body('Filter_array')[16],'VA')?[0],' ')),2)]

 

In this, I'm getting the left part of "VA" and then using the length of array -2, I'm getting the city name.

 

Hope this helps 🙂


Kind Regards,
Shaik Sha
________________________________________________________________________

If I have answered your question, please mark the post as Solved.
If you like my response, please give it a Thumbs Up.

MrAutomate
Helper III
Helper III

@shaik 

Yes, that worked perfectly.  I need to learn more on powerautomate, can you explain this section to help me understand how to apply for future usese?  thanks!

?[sub(length(split(split(body('Filter_array')[16],'VA')?[0],' ')),2)]

Mister_Shaik
Super User
Super User

@MrAutomate , Sure

 

As you know, we need to pass the index of element we need to fetch from the array that was split by space.

 

Using the Length() function I got the total length of splitted array. Then, as the index of array usually start from 0 and not 1, we need to subtract 1 from the length. Also, there is one extra space at the end, that means we want last but 1 element, not the final element. For this we need to subtract 1 again from the length. I've used the sub() function to do the subtraction.

 

To summarize, the length() function gives the total items in the array, and using the sub() function we are subtracting the length by 2 and getting the exact index where the city name is.

 

 

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (3,764)