cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Change word color in string if word is in Table

Hi,

 

I am trying to format words within a string depending on if that word exists in a table column. For example, if I have the following in an HtmlText:

Hello world, my name is X

And I have the single-column table:

Result
---------
Bob
Drew
X
name

How can I get my string to show up as:

"Hello world, my name is X"

 

I've tried doing something with Substitute() and Filter(), but I have not been able to achieve anything. Any help is appreciated

1 ACCEPTED SOLUTION

Accepted Solutions
Dual Super User
Dual Super User

Re: Change word color in string if word is in Table

Hi @Anonymous 

 

If your string could be of any length, you can create a collection with all the words and later perform a concatenation to show the result in desired format:
 
Expression:
ForAll(Split(testvar," "),If(Result in NamesList,Collect(test123,"<font color=Red>"&Result&"</font>"),Collect(test123,Result)))
 
Here, test123 is the name of my local collection, and to use this on the HTML text you can try out below expression:
Expression: Concat(test123,Value," ")sd.png

 

Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

4 REPLIES 4
Dual Super User
Dual Super User

Re: Change word color in string if word is in Table

Hi @Anonymous 

 

Can you try out the below expression:
"Hello world, my <font color="&If("X" in NamesList,"Red","Black")&">name</font> is <font color="&If("X" in NamesList,"Red","Black")&">X</font>"
Here, NamesList is the name of one column table that I have used in my scenario. Please replace this with the actual value.cc.png

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Anonymous
Not applicable

Re: Change word color in string if word is in Table

@yashag2255 

 

That would work, except the string is dependent on a variable. If I had a variable sentence, I would not be able to hard code the font colors in html as every word in sentence would be constantly changing. I hope that makes sense.

 

Is there a way to possibly loop through all the words in the string using ForAll() or something similar?

 

Thanks!

Dual Super User
Dual Super User

Re: Change word color in string if word is in Table

Hi @Anonymous 

 

If your string could be of any length, you can create a collection with all the words and later perform a concatenation to show the result in desired format:
 
Expression:
ForAll(Split(testvar," "),If(Result in NamesList,Collect(test123,"<font color=Red>"&Result&"</font>"),Collect(test123,Result)))
 
Here, test123 is the name of my local collection, and to use this on the HTML text you can try out below expression:
Expression: Concat(test123,Value," ")sd.png

 

Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

Anonymous
Not applicable

Re: Change word color in string if word is in Table

@yashag2255 It Worked! Thank you so much! 

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (4,914)