cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DaleZ
Helper I
Helper I

Highlight searched text in gallery results

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)
        )
    )
)

 

1 ACCEPTED SOLUTION

Accepted Solutions
DaleZ
Helper I
Helper I

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! 

View solution in original post

12 REPLIES 12
WarrenBelz
Super User
Super User

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

gabibalaban
Dual Super User
Dual Super User

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

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

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

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>"
)

 

 

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

        )
    )

  

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

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 !

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?

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (1,376)