I'm trying to do the following inside a datacard in a gallery. I also attempted to add an Icon with conditional display but can't get the icon control inside the datacard.
What I want to do is display ThumbsUp or ThumbsDown depending on the underlying yes/no in the SP list. I thought this would be easy but I cannot for the life of me figure out the syntax.
Here are the things I've tried already within one big code block. The top works and displays "true" or "false".
ThisItem.Completed
//If(ThisItem.Completed, ":thumbsup:", "Nope")
//If(ThisItem.Completed, Icon.ThumbsUpFilled, "Nope")
/*If(
ThisItem.Completed,
Icon.ThumbsUp,
Icon.ThumbsDown
)*/
The three commented attempts above all result in the correct evaluation but show the text within the logic and not the Icon itself.
I figured it out. Seems you can't do it in the Tree View. Or at least I couldn't.
Solution was to click on the Gallery in the Canvas, click the Pencil icon to Edit the Gallery, then Insert.
Bob's your uncle. Thank you for attending DC's Powerapps for Fools.
Appearing daily as he solves silly problems and then tells himself he's a genius.
Both of those things will work if I put an Icon outside of the gallery item. But that doesn't really solve my problem.
I want a visual indicator inside the ThisItem based on the underlying value.
When I add "Completed" as a Field, it automatically adds it as a Label and populates it with true or false which obviously corresponds to Yes/No in the SP list.
Instead of displaying true or false, I want to convert that into a visual.
I have this kind of thing working for a chevron indicating sorting. But that's outside of a gallery.
What I'm trying to figure out how to do is have an icon inside of a gallery that's dependent on the source data.
You can't include an icon in a label. Use an icon control for that over the label control and put it as is suitable for you.
The code:
If(
ThisItem.Completed,
Icon.ThumbsUp,
Icon.ThumbsDown
)
should work.
Hope it helps !
Hi @DCHammer
You need to use the Icon property of the icon control to specify which icon to display, not the Text property. The Text property is for labels, not icons.
So, your formula for the icon control should look like this:
Icon = If(ThisItem.Completed, Icon.ThumbsUp, Icon.ThumbsDown)
Visible = If(ThisItem.Completed, true, false)
If you have any questions or feedback, please let me know. Have a great day! 😊
-----------------------
PowerYsa Power Platform Enthusiast [LinkedIn] | [Youtube]
I love to share my knowledge and learn from others. If you find my posts helpful, please give them a thumbs up 👍 or mark them as a solution ✔️. You can also check out my [@PowerYSA] for some cool solutions and insights. Feel free to connect with me on any of the platforms above. Cheers! 🍻
WarrenBelz
146,653
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,999
Most Valuable Professional