cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Remove last line after comma of appended string

Im parsing a list of emails from a table but the last rows is not an email, how can I remove it from the extraction? The only change will be the #s of records all other characters will remain the same.
power.JPG

9 REPLIES 9
Responsive Resident
Responsive Resident

Hi @carlosdajer , I may have a solution for you.

This works only if your data is always formatted like you've described and the second-to-last line always has an email ending with ".com".

Here's the expression.

concat(Substring(variables('varemovelastline'),0,add(4,lastIndexOf(variables('varemovelastline'),'com'))),']')
What it's doing

Gets position to the " of the last "com"
add(4,lastIndexOf(variables('varemovelastline'),'com'))

Gets the string up to the last "com" and adds a "]" to close the array.
concat(Substring(variables('varemovelastline'),0,add(4,lastIndexOf(variables('varemovelastline'),'com'))),']')

 

 

 

 

Hope this helps,

Aman

 

------------------------------------------------------------------------------------------------------
If my post helps you with your problem or answers your question, please mark it Solved or Answered. This helps anyone with similar challenges. If you like my response, please give it a Thumbs Up.
------------------------------------------------------------------------------------------------------

Solution Specialist
Solution Specialist

@carlosdajer - You can use split function to split the string by comma as delimiter and store it to array variable. Then just ignore the last element of array and use the rest.

 

Like and Mark this as an answer if it resolves your issue.

Please Like and Mark this as Answer if it resolves your Issue.

Power Automate Community

@PrasadAthalye  Thanks for the answer but what I want is actually that, how can I ignore the last and keep the rest (emails)

@carlosdajer

Use the below expressions on your variable

substr(yourvariable,0, length(your variable) - 1)

 

If this post helps you with your problem, please mark your as Accepted solution.If you like my response, please give it a Thumbs Up.

Hi @carlosdajer 

Expression in action.

PAUG_moretextfun2.PNG

 

It works on the test but when I use my append to string variable with the new expression it shows like this:power.JPG

How can I extract it so it will keep the same format

@carlosdajer 

Do you mean it looks like an array?

 

If this post helps you with your problem, please mark your as Accepted solution.If you like my response, please give it a Thumbs Up.

Yes. To give more context, Im extracting a table, grabbing the email column, joining the emails together separated by comma using join function, but last row is not an email (Grand Total (22 records), @Amanthaper  Solution works on a testing enviorement (inputting the data) but with the join function or the strings coming out of it, I can't make it work.

See image below

2.JPG1.JPG

@carlosdajer  - Thanks for the context. Instead of Join, can you run a for each loop on the table? Then inside the loop add a condition? Within the condition, check if string contains '@'  or not, If yes, append the string to string variable along with comma.

 

This should give you exactly what you are looking for...

 

Like and Mark this as answer if it resolves your issue.

Please Like and Mark this as Answer if it resolves your Issue.

Power Automate Community

Helpful resources

Announcements
PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Top Solution Authors
Users online (4,457)