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

How can I replace text in a string by matching the text to a table like with a VLOOKUP?

I have a string containing placeholder text that I want to dynamically replace in a single action. Here is fake text as an example:

 

"This [Product]'s dimensions are [Dimensions]."

 

If this were an Excel file, I would create a table as follows:

 

PlaceholderText
[Product]cabinet
[Dimensions]10x10

 

I assume I will need some kind of Apply to Each loop that operates over an array containing the table above or something like that, but I have no idea where to start.

4 REPLIES 4
DeepakS
Super User
Super User

Hi @dehmos27 

 

it all depends how you are getting the data, so for an example if you will get data as an array or collection you can add "Apply to each" action in flow and use following expression (sample) in 'compose':

concat('This ',items('Apply_to_each')['Product'],' dimensions are ', items('Apply_to_each')['Dimensions'])

above expression output will be like - "This cabinet dimensions are 10x10"

 

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

 

 

@DeepakS , thank you for your reply. The text in question is coming from a SharePoint list, so concatenation is out. I know I will need to use some kind of Replace action. The path I am trying to pursue is having a SharePoint list that maps the placeholders to the corresponding column titles in a second SharePoint list like below:

 

LISTA

 

PlaceholderMapping
[Product]Product
[Dimensions]Dimensions 

 

LISTB

ProductDimensions
Cabinet10x10
Credenza4X4

 

What I want to do is a replace in an Apply to Each that loops through the list of placeholders (LISTA.Placeholder) and replaces them in the text string with the value in the column in LISTB specified by the LISTA.Mapping column.

 

For example, if the Apply to each is on the [Product] placeholder, it replaces the placeholder with the value in the Dimensions column in LISTB because that is where I have mapped the placeholder in LISTA.

 

I hope all of that makes sense. Finding it difficult to explain my goal.

 

Perhaps a better question for this post would be "How do I dynamically specific which column I want to pull a value from in a SharePoint list?"

Hi @dehmos27 , I may be little confuse, could you please share a sample final result that you are trying to get after all mapping?

 

Are you trying to get something like this?

PlaceholderMapping
CabinetProduct
10x10Dimensions 
CredenzaProduct
4x4Dimensions 

 

Hi @dehmos27 

 

Hope I haven't misunderstood but within SharePoint you can have a calculated column with a formula of:

=CONCATENATE("This ", Product," dimensions are ",Dimensions)

 

This will show as "This Cabinet dimensions are 10x10" requiring no Power Automate as the column will update every time you update the item.

Best regards,

Bradley
If this post helps, then please consider Accept it as the solution to help the other members find it more

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

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 Solution Authors
Users online (1,897)