cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sudosaurus
Post Prodigy
Post Prodigy

Conditionally show image in Gallery

Hello,

 

In my PowerApp I have a gallery of items linking to a SharePoint form on another screen.


What I'm trying to do is conditionally display images against each item depending on the value they are linked to in the form.
For reference, the images in my form are conditionally displayed in the based on true/false values of a toggle control.

 

The below shows the Toxic image being displayed when the true/false toggle for this is selected in the SharePoint form.

sudosaurus_2-1643281146848.png

 

I am finding if I add an image control to my gallery and set the formula of the Image function to the below, this seems to display the "Oxidising" image to all rows, even if they're not set to "True" in the SharePoint item.
sudosaurus_0-1643280973240.png

sudosaurus_1-1643281064876.png

 

Any thoughts?

8 REPLIES 8
WarrenBelz
Super User
Super User

Hi @sudosaurus ,

You did not post the field name (and the image name needs to be different to the field name), but if this is the image beside the Oxidising field

If(
   ThisItem.OxidisingField,
   Oxidising
)

 

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

AmDev
Super User
Super User

Hi @sudosaurus 

 

When inside a Gallery, the expression must be written in the context of the item for each row i.e. ThisItem.

 

Is it just this one image you are trying to show and hide on each row? - if so you can just leave the image property as Oxidising and add this to the 'Visible' property of the image ThisItem.Oxidising (assuming the field is called 'Oxidising')

 

Hope this helps

 

 

 

 

So you could try If(ThisItem.Oxidising, Oxidising, blank) - I take it 'blank' is a blank image in your app?

sudosaurus
Post Prodigy
Post Prodigy

Thanks @WarrenBelz 

Got it working now. 

Can you think of any way I can get the items to display on the left of the column if only one or two of them are showing rather than this sporadic view?

sudosaurus_0-1643289494905.png

 

Hi @sudosaurus ,

Can you please elaborate on that?

sudosaurus
Post Prodigy
Post Prodigy

@WarrenBelz 

 

These Hazard Classifcation symbols on the right are displayed based on a toggle in a list form on another screen.

 

Where I use this formula to display the images and this works correcty:

What I want to do is for the items for example (fairy liquid) I want the icon that is showing to be left-justified and sitting in line with the icons on the other rows, just so that they dont appear sporadically in the gallery.

sudosaurus_0-1643317541824.png


I've tried adding the images into a container but still cant seem to figure this out.

sudosaurus_1-1643317670834.png

Does this help?

Hi @sudosaurus ,

The easiest way is to make each icon's X position the X of the one to the left plus the Width of the one to the left, then have a logic on each that if they are not Visible, have a width of 0 (zero)

 

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

sudosaurus
Post Prodigy
Post Prodigy

@WarrenBelz 

 

As they're in a container, I guess by doing so, if the one to the left is visible (if the item is later edited) then it will just shift the one on top of it along?

Would this be the right solution? If(Oxidising(ThisItem.Oxidising)="No",true,false)

Hi @sudosaurus ,

I do not use containers, but as long as you follow the logic and it is either visible or not, then the variable X will work.

 

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

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Top Solution Authors
Top Kudoed Authors
Users online (1,539)