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 / Highlight searched tex...
Power Apps
Answered

Highlight searched text in gallery results

(0) ShareShare
ReportReport
Posted on by 34

My gallery (Item code below) allows users to type in a text input (ContentDesSearch) and results containing any of those words in the Content Description column are shown. I want to highlight that text in the results. Can't figure out where to even enter such an instruction.

 

 

With({_splits: Split(ContentDesSearch.Text, " ")},
 Filter(ContentIndex,
 (If (IsBlank(CollateralTypeDrop.Selected.Value),true,
CollateralTypeDrop.Selected.Value in Concat('Collateral type',Value&",")) &&
 (If (IsBlank(TechDrop.Selected.Value),true,
TechDrop.Selected.Value in Concat('Tech',Value&",")))) &&
 (
 (Sum(ForAll(_splits, {Value: If(Result in 'Content Description', 1, 0)}), Value) = CountRows(_splits)) ||
 Sum(ForAll(_splits, {Value: If(Result in Concat('Collateral type',Value&","), 1, 0)}), Value) = CountRows(_splits) ||
 Sum(ForAll(_splits, {Value: If(Result in Concat('Tech',Value&","), 1, 0)}), Value) = CountRows(_splits)
 )
 )
)

 

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    155,940 Most Valuable Professional on at

    Hi @DaleZ ,

    Unfortunately, the only option in Power Apps to change part of the text would be a HTML text box, but then you need to "hard code" what you want bold etc, so not really possible.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • CU-18081211-6 Profile Picture
    9,272 Moderator on at

    @DaleZ ,

    I think that it is achievable only if you use a HTML text control inside the gallery. 

     Use as items property of the Gallery this formula, where the searchable text is stored in SearchTextControl (text input control):

     

     

    With({_splits: Split(ContentDesSearch.Text, " ")},
     Substitute(
     Filter(ContentIndex,
     (If (IsBlank(CollateralTypeDrop.Selected.Value),true,
    CollateralTypeDrop.Selected.Value in Concat('Collateral type',Value&",")) &&
     (If (IsBlank(TechDrop.Selected.Value),true,
    TechDrop.Selected.Value in Concat('Tech',Value&",")))) &&
     (
     (Sum(ForAll(_splits, {Value: If(Result in 'Content Description', 1, 0)}), Value) = CountRows(_splits)) ||
     Sum(ForAll(_splits, {Value: If(Result in Concat('Collateral type',Value&","), 1, 0)}), Value) = CountRows(_splits) ||
     Sum(ForAll(_splits, {Value: If(Result in Concat('Tech',Value&","), 1, 0)}), Value) = CountRows(_splits)
     )
     ),
     ContentDesSearch.Text,
     "<b><font color=blue>"&ContentDesSearch.Text&"</font></b>"
    )

     

     

    Hope it helps !

  • DaleZ Profile Picture
    34 on at

    Sorry, what is SearchTextControl? A text input i need to add? Should it replace my ContentDesSearch input?

  • CU-18081211-6 Profile Picture
    9,272 Moderator on at

    @DaleZ ,

    It's your ContentDesSearch control. Sorry I didn't notice that you already named it. I updated my formula accordingly.

    Formula will use bold char and blue color to identify the ContentDesSearch.Text in your gallery. 

  • DaleZ Profile Picture
    34 on at

    Thank you! My code looks like this now but i'm getting an error. I can't see what's wrong though!?

    With({_splits: Split(ContentDesSearch.Text, " ")},
     Substitute(
     Filter(ContentIndex,
     (If 
     (IsBlank(CollateralTypeDrop.Selected.Value),true,CollateralTypeDrop.Selected.Value in Concat('Collateral type',Value&",")) &&
     (If 
     (IsBlank(TechDrop.Selected.Value),true,TechDrop.Selected.Value in Concat(Tech,Value&",")) &&
     (If 
     (IsBlank(ThemeDrop.Selected.Value),true,ThemeDrop.Selected.Value in Concat(Theme,Value&",")) &&
     ((Sum(ForAll(_splits, {Value: If(Result in 'Content Description', 1, 0)}), Value) = CountRows(_splits)) ||
     Sum(ForAll(_splits, {Value: If(Result in Concat('Collateral type',Value&","), 1, 0)}), Value) = CountRows(_splits) ||
     Sum(ForAll(_splits, {Value: If(Result in Concat(Tech,Value&","), 1, 0)}), Value) = CountRows(_splits)||
     Sum(ForAll(_splits, {Value: If(Result in Concat(Theme,Value&","), 1, 0)}), Value) = CountRows(_splits))
     )
     )
     )
     )),ContentDesSearch.Text,"<b><font color=blue>"&ContentDesSearch.Text&"</font></b>"
    )

     

     

  • CU-18081211-6 Profile Picture
    9,272 Moderator on at

    @DaleZ ,

    I don't see the Substitute() function. Have you miss it ? Try this ...

    With({_splits: Split(ContentDesSearch.Text, " ")},
     Substitute(
     Filter(ContentIndex,
     (If 
     (IsBlank(CollateralTypeDrop.Selected.Value),true,CollateralTypeDrop.Selected.Value in Concat('Collateral type',Value&",")) &&
     (If 
     (IsBlank(TechDrop.Selected.Value),true,TechDrop.Selected.Value in Concat(Tech,Value&",")) &&
     (If 
     (IsBlank(ThemeDrop.Selected.Value),true,ThemeDrop.Selected.Value in Concat(Theme,Value&",")) &&
     ((Sum(ForAll(_splits, {Value: If(Result in 'Content Description', 1, 0)}), Value) = CountRows(_splits)) ||
     Sum(ForAll(_splits, {Value: If(Result in Concat('Collateral type',Value&","), 1, 0)}), Value) = CountRows(_splits) ||
     Sum(ForAll(_splits, {Value: If(Result in Concat(Tech,Value&","), 1, 0)}), Value) = CountRows(_splits)||
     Sum(ForAll(_splits, {Value: If(Result in Concat(Theme,Value&","), 1, 0)}), Value) = CountRows(_splits))
     )
     )
     )
     ),
     ContentDesSearch.Text,
     "<b><font color=blue>"&ContentDesSearch.Text&"</font></b>"
    
     )
     )

      

  • DaleZ Profile Picture
    34 on at

    Yeh sorry I edited my previous comment when i noticed that. Using what you gave just now but it's still giving an error. 

  • CU-18081211-6 Profile Picture
    9,272 Moderator on at

    Can you show me the error ?

    Are you sure that your filter formula worked fine before ?

    I spent some time on the formula to figure it out what it is and here is my new proposal:

    With(
     {_splits: Split(ContentDesSearch.Text, " ")},
     Substitute(
     Filter(
     ContentIndex,
     If 
     (IsBlank(CollateralTypeDrop.Selected.Value),
     true,
     CollateralTypeDrop.Selected.Value in Concat('Collateral type',Value&",")) &&
     If 
     (IsBlank(TechDrop.Selected.Value),
     true,
     TechDrop.Selected.Value in Concat(Tech,Value&",")) &&
     If 
     (IsBlank(ThemeDrop.Selected.Value),
     true,
     ThemeDrop.Selected.Value in Concat(Theme,Value&",")) &&
     (
     Sum(ForAll(_splits, {Value: If(Result in 'Content Description', 1, 0)}), Value) = CountRows(_splits) ||
     Sum(ForAll(_splits, {Value: If(Result in Concat('Collateral type',Value&","), 1, 0)}), Value) = CountRows(_splits) ||
     Sum(ForAll(_splits, {Value: If(Result in Concat(Tech,Value&","), 1, 0)}), Value) = CountRows(_splits)||
     Sum(ForAll(_splits, {Value: If(Result in Concat(Theme,Value&","), 1, 0)}), Value) = CountRows(_splits)
     )
     ),
     ContentDesSearch.Text,
     "<b><font color=blue>"&ContentDesSearch.Text&"</font></b>"
    
     )
    )

    Hope it helps !

  • DaleZ Profile Picture
    34 on at

    Yeh my formula worked nicely before. No errors. Using what you provided though (as much as I sincerely appreciate it!) is fully redlined. The inspector doesn't give any useful info. 27 errors.

     

    I've tried fiddling with it, and see the intention, but I cant figure out what's wrong myself.

    Maybe it isn't possible?

  • Verified answer
    DaleZ Profile Picture
    34 on at

    Nevermind! I figured out a workaround in the end. I left the gallery code alone, and instead inserted an HTML text box and positioned it exactly over the top of my description label:

     

    Substitute(DescriptionLabel.Text,
    ContentDesSearch.Text,
    "<span style=""background-color:yellow"">" & ContentDesSearch.Text & "</span>"
    )

     

    Then made the font colour of my original label the same as my background colour so it's invisible. And voila! 

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

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 296 Most Valuable Professional

#2
11manish Profile Picture

11manish 224

#3
Valantis Profile Picture

Valantis 181

Last 30 days Overall leaderboard