cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Resolver I
Resolver I

Replacing words in string with values from a collection.

Hi,

 

I have a string with multiple words delimited with ";". "Word1; Word2; Word3; Word4; Word5"

 

I also have a collection with the words from the string, but also containing a value for each word.

 

Capture.PNG

 

 

 

 

 

What I want to do is to iterate through the string and for each word get the optionvalue from the collection where the words match and create a new string containing the optionvalues.

 

Does anyone know how to best do this?

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Replacing words in string with values from a collection.

Hi @McMonty ,

Could you please share a bit more about your scenario?

Do you want to replace the each word within the string with the matching OptionValue from the collection?

 

Based on the needs that you mentioned, I think the ForAll function could achieve your needs. I have made a test on my side, please consider take a try with the following workaround:

Set the Text property of a Label to following:

Concat(
       ForAll(
              Split("Word1; Word2; Word3; Word4; Word5", "; "),
              If(
                  Result in Collection.Name,
                  LookUp(Collection, Name = Result, OptionValue)
              )
       ),
       Value & "; "
)

 

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Highlighted
Super User
Super User

Re: Replacing words in string with values from a collection.

Try this:

 

AddColumns(Split(YourDelimitedString,";"),"OptionValue",LookUp(YourOptionValueTable,Result=Name).OptionValue)

 

Where YourDelimitedString is "Word1; Word2; Word3; Word4; Word5" and YourOptionValueTable is the table you showed.

If your string has spaces between the semicolon and the next word like your example, you'll need to use this:

Substitute("Word1; Word2; Word3; Word4; Word5"," ","")

 

Highlighted
Community Support
Community Support

Re: Replacing words in string with values from a collection.

Hi @McMonty ,

Could you please share a bit more about your scenario?

Do you want to replace the each word within the string with the matching OptionValue from the collection?

 

Based on the needs that you mentioned, I think the ForAll function could achieve your needs. I have made a test on my side, please consider take a try with the following workaround:

Set the Text property of a Label to following:

Concat(
       ForAll(
              Split("Word1; Word2; Word3; Word4; Word5", "; "),
              If(
                  Result in Collection.Name,
                  LookUp(Collection, Name = Result, OptionValue)
              )
       ),
       Value & "; "
)

 

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (6,840)