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)
)
)
)
Solved! Go to Solution.
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!
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
@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?
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
200 | |
52 | |
41 | |
39 | |
35 |
User | Count |
---|---|
261 | |
86 | |
71 | |
69 | |
66 |