cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
yjamous
Helper IV
Helper IV

How to dynamically change Gallery Image

Hi

I've inserted a gallery that gets the data from a SharePoint List. I wanted to change the item image in the gallery so that if the Request Type is "Application Training Request", then I want to show "Image1.jpg". If the Request Type is "Service Support Request", I want to show "Image 2.jpg".

Both images are uploaded to the PowerApps Media

 

 

yjamous_0-1622840729177.png

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
WarrenBelz
Super User
Super User

Hi @yjamous ,

If 'Request Type' is a Choice field, you need

Switch(
   ThisItem.'Request Type'.Value,
   "Application Training Request", 
   'Image 1',
   "Service Support Request", 
   'Image 2'
)

 

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.

View solution in original post

Ok, I used this instead and it worked 🙂

 

If( ThisItem.'Request Type'.Value="Service Support Request",'Image 1','Image 2')

 

But I wouldn't have figured it out without your post @WarrenBelz 

View solution in original post

7 REPLIES 7
WarrenBelz
Super User
Super User

Hi @yjamous ,

In the Image property, put something like this (the names may not be exactly correct)

Switch(
   ThisItem.'Request Type',
   "Application Training Request", 
   'Image 1',
   "Service Support Request", 
   'Image 2'
)

 

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.

RandyHayes
Super User
Super User

@yjamous 

Set your Image property on the image to:

Switch(ThisItem.RequestType,
    "Application Training Request", Image1,
    "Service Support Request", Image2
)

This assumes you have imported the two images and they are named Image1 and Image2.  Otherwise, adjust as needed.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Thanks @WarrenBelz 

For some reason, it's not accepting the syntax.

By the way, the field I'm checking "Request Type" is dropdown in my SharePoint list. Not sure if this makes a difference.

 

yjamous_0-1622842014614.png

 

WarrenBelz
Super User
Super User

Hi @yjamous ,

If 'Request Type' is a Choice field, you need

Switch(
   ThisItem.'Request Type'.Value,
   "Application Training Request", 
   'Image 1',
   "Service Support Request", 
   'Image 2'
)

 

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.

RandyHayes
Super User
Super User

@yjamous 

That is not an error message!  The formula editor is never able to evaluate expressions that have ThisItem in them.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Ok, I used this instead and it worked 🙂

 

If( ThisItem.'Request Type'.Value="Service Support Request",'Image 1','Image 2')

 

But I wouldn't have figured it out without your post @WarrenBelz 

Thanks @yjamous ,

So is this now solved?

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,317)