web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Change word color in s...
Power Apps
Answered

Change word color in string if word is in Table

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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

Categories:
  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    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!

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

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

  • Verified answer
    yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    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!
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @yashag2255 It Worked! Thank you so much! 

  • Abhishek Gawde Profile Picture
    96 on at

    Really amazed at the ingenuity and simplicity of the solution @yashag2255  🙂

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 248 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 192 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard