cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
carlosdajer
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
Amanthaper
Super User
Super User

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.
------------------------------------------------------------------------------------------------------

PrasadAthalye
Super User
Super User

@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.

Blog: here

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.

Blog: here

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
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Kudoed Authors
Users online (3,076)