cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
HeathB
New Member

Display and swap an image based on SharePoint List choice column

Hi folks,

Very new to PowerApps so apologies if this is bleedingly obvious. 🙂

I'm building an app which will display an icon based on the status of the choice column of a SharePoint list which is shown as a drop-down menu.

If the user selects status A, B or C, then I want to be able to display an image in the app, based on that choice.

The images are uploaded into the media section, the gallery to display the images exists, I just can't figure out how to -

1) Display the image based on the corresponding list data

2) Swap those images depending on said choice

Thanks for the help!


1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@HeathB 

Welcome to PowerApps!!

 

In your Image property, set a formula such as this (assuming you are in a Gallery or a Form):

Switch(ThisItem.yourChoiceColumn.Value,
   "yourStatusAChoiceName", imageforStatusA,
   "yourStatusBChoiceName", imageforStatusB,
   "yourStatusCChoiceName", imageforStatusC
)

 I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

6 REPLIES 6
RandyHayes
Super User III
Super User III

@HeathB 

Welcome to PowerApps!!

 

In your Image property, set a formula such as this (assuming you are in a Gallery or a Form):

Switch(ThisItem.yourChoiceColumn.Value,
   "yourStatusAChoiceName", imageforStatusA,
   "yourStatusBChoiceName", imageforStatusB,
   "yourStatusCChoiceName", imageforStatusC
)

 I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

Hi @RandyHayes!

Spot on! That's exactly what I was looking for and it's working well.

Appreciate your expertise. 🙂

joeinmay
Resolver II
Resolver II

Example:

Step1:
Upload all your images say: img1,img2,img3,img4 etc..

Step2:
Insert dropdown field: "Dropdown1"
On the Dropdown1 Onselect Property:
ClearCollect(MyImages, {Value:"A", Image: img1},
{Value:"B", Image: img2},
{Value:"C", Image: img3},
{Value:"D", Image: img4},{Value:"E", Image: img5}
)
Step3:
Insert Media Image: "Image1"
On the Image1 Image Property: LookUp(MyImages,Value=Dropdown1.Selected.Value,Image)

RandyHayes
Super User III
Super User III

@joeinmay 

Why a Collection?  There is no need for one.  And if you base this on the OnSelect Action of the DropDown, it will perform this action over and over. 

 

If you want to do this from a table, then get rid of the OnSelect Action and change your Image formula  to the following:

LookUp(Table(
    {Value:"A", Image: img1},
    {Value:"B", Image: img2},
    {Value:"C", Image: img3},
    {Value:"D", Image: img4},
    {Value:"E", Image: img5}),
    Value=Dropdown1.Selected.Value,
    Image
)

Collections are app 'expensive' and are meant for in-memory extendible datasources (add/remove rows).  If you are dealing with a Static list, either use the list directly as above or set to a variable.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

@RandyHayes 

Thank you I appreciate your solution to the problem.

Mine was an example.

A problem can have multiple solutions. 😁

RandyHayes
Super User III
Super User III

@joeinmay 

Understood for the example.  My focus was on the Collection - they are WAY overused and for the wrong purpose.  The unfortunate part is that most of the docs use them in their examples.  And just like variables, they are, again, overused for the wrong purpose.  A collection carries an overhead to it for add and remove operations.  A static table that will never change within the app should not go into a collection.

I wasn't trying to smash your example, I was just shooting at the collection - which is why I provided the alternative of your example without the expensive collection. 😁

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (29,151)