web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Change image in form f...
Power Apps
Answered

Change image in form from choice field selection

(1) ShareShare
ReportReport
Posted on by 16
I have a choice field in one list (This has been added to the canvas).
I want to display an image from a different SharePoint library when a user selects a value from the choice list.
 
NOTE:  I have added a TITLE column to the image library.
 
I have tried both the IF and the Switch and the images do not appear.  I have also tried the LOOKUP.  And it still does not work.
 
Switch(
VBranch,
"Army", LookUp(Documents, Title = Army").Image,
"Airforce", LookUp(Documents, Title = "Airforce").Image,
"Navy", LookUp(Documents, Title = "Navy").Image,
"Civilian", Lookup(Documents, Title = "Civilian").Image
)
 
 
I have also tried the IF
If(
VBranch.Selected.Value = "Army", "ImageURL1",
VBranch.Selected.Value = "Airforce", "ImageURL2",
VBranch.Selected.Value = "Navy", "ImageURL3"
VBranch.Selected.Value = Civilian", "ImageURL4"
)
 
BTW, I have added the connection to the Documents library where the images are stored.
Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,084 Most Valuable Professional on at
    Assuming this is a SharePoint Library and VBranch  is the drop-down name
    LookUp(
       Documents, 
       Title = VBranch.Selected.Value
    ).'{Thumbnail}'.Large
    If VBranch is a Variable, you leave off .Selected.Value
     
    Please click Does this answer your question 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 a Like.
    Visit my blog Practical Power Apps    LinkedIn   
  • CU08031624-0 Profile Picture
    16 on at
    The recommendation doesn't work.
     
    This again is what I have:
    Documents library with 4 images. each image has the title of:  Army, Airforce, Navy, Civilian
     
    A custom list has a choice field of Army, Airforce, Navy, civilian.
    On the canvas I have renamed the Choice field to VBranch.
     
    If (Vbranch.Selected.Value = "Army", LOOKUP (Documents, TITLE = VBranch.Selected.Value).image,
    Vbranch.Selected.Value = "AIrforce", LOOKUP (Documents, TITLE = VBranch.Selected.Value).image,
    Vbranch.Selected.Value = "Navy", LOOKUP (Documents, TITLE = VBranch.Selected.Value).image
    Vbranch.Selected.Value = "Civilian", LOOKUP (Documents, TITLE = VBranch.Selected.Value).image)
     
    When I Do that I get and error that states "If has some invalid arguments.
     
    When I try: 
    If (Vbranch.Selected.Value = "Army", LOOKUP (Documents, TITLE = VBranch.Selected.Value).'{Thumbnail}'.Large,
    Vbranch.Selected.Value = "AIrforce", LOOKUP (Documents, TITLE = VBranch.Selected.Value).'{Thumbnail}'.Large,
    Vbranch.Selected.Value = "Navy", LOOKUP (Documents, TITLE = VBranch.Selected.Value).'{Thumbnail}'.Large,
    Vbranch.Selected.Value = "Civilian", LOOKUP (Documents, TITLE = VBranch.Selected.Value).'{Thumbnail}'.Large)
     
    I get the same error.
  • WarrenBelz Profile Picture
    153,084 Most Valuable Professional on at
    Let's get down to basics here so I can be sure what we are dealing with:-
    • You have a SharePoint Document Library called Documents with four files in it
    • The file in each record is of an image type (jpg, png etc)
    • You have a Text field Title in this Library containing the values Army, Airforce, Navy & Civilian
    • You have a Drop-down or Combo Box called Vbranch containing the same options as above
    • You have an Image control you want to display the selected picture in
    Is all of that accurate ? If so what I posted is correct (example below has exactly the same code except my Library has a different name). What is different in yours to this ?
     
     
    Please click Does this answer your question 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 a Like.
    Visit my blog Practical Power Apps    LinkedIn   
  • CU08031624-0 Profile Picture
    16 on at
    I have TWO Lists:
    List one:  Rank, LastName, Branch
    Library Two:  Title, filename, Image(type Image).
     
    On my canvas I have renamed the List One, field heading BRANCH to VBranch.
    When someone selects Army from the VBranch option (from list one), I want the image from the library that matches the TITLE to display the image (From list two).
     
    I have tried 
    If(VBranch.Selected.Value = "Army", LookUp('Documents', Title = "Army.Selected.Value", Image.Medium),
    VBranch.Selected.Value = "Airforce", LookUp('Documents', Title = "Airforce.Selected.Value", Image.Medium),
    VBranch.Selected.Value = "Navy", LookUp('Documents', Title = "Navy.Selected.Value", Image.Medium),
    VBranch.Selected.Value = "Civilian", LookUp('Documents', Title = "Civilian.Selected.Value", Image.Medium))
     
     
     
    If(VBranch.Selected.Value = "Army", LookUp('Documents', Title = "Vbranch.Selected.Value").'{Thumbnail}'.Large,
    VBranch.Selected.Value = "Airforce", LookUp('Documents', Title = "Vbranch.Selected.Value").'{Thumbnail}'.Large,
    VBranch.Selected.Value = "Navy", LookUp('Documents', Title = "Vbranch.Selected.Value").'{Thumbnail}'.Large,
    VBranch.Selected.Value = "Civilian", LookUp('Documents', Title = "Vbranch.Selected.Value").'{Thumbnail}'.Large)
  • Verified answer
    WarrenBelz Profile Picture
    153,084 Most Valuable Professional on at
    If I can understand exactly what you have there, this is not difficult.
     
    Are you saying that you have added to your Library Documents an Image column (why - you have to add a file to create the record anyway). The syntax I posted '{Thumbnail}'.Large refers to the actual file in a Library record, so what do you use to create the file before adding another file content to the Image field ?
     
    Secondly are you now saying that VBranch is not the name of the drop-down, but the new name of the field in List1 containing the information of the Branch? If so, I need to know the name and Items of the dropdown. The problem you have to date is that you are referring to the field name, not the drop-down name in your LookUp.
     
    For the purposes of moving this forward as quickly as possible, I am going to make a few more assumptions. Firstly based on my (still a bit unclear) understanding of what you have now posted, I will suggest the following: -
    Make the Items of the Dropdown (I will call it ddBranch below - change this and List1 to the actual List and Dropdown names) 
    Distinct(List1, VBranch)
    or
    ["Army", Airforce", Navy", "Civilian"]
    This will then display a list of branches in the drop-down. Now the Image property of your Image control - again assuming that the Title field of Documents contains the Branch related to the image.
    LookUp(
       Documents, 
       Title = ddBranch.Selected.Value
    ).Image.Full
    Just a note that Image columns are still a bit "buggy" - why not simply file the images in the Library file (which I assumed initially) ? Also Image is a bad field name as it is a Reserved Word in Power Apps.
     
    Please click Does this answer your question 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 a Like.
    Visit my blog Practical Power Apps    LinkedIn   
  • WarrenBelz Profile Picture
    153,084 Most Valuable Professional on at
    A quick follow-up to see if you received the answer you were looking for or if you need further assistance.

    Please ✅Does this answer your question 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 a Like.
    Visit my blog Practical Power Apps    LinkedIn   
  • CU08031624-0 Profile Picture
    16 on at
    I figured it out.
    This is the formula that worked for me (Note:  I changed the image column name to Photo.)
    If(VBranch.Selected.Value = "Army", LookUp(StockImages, Title = VBranch.Selected.Value, Photo).Large,
    VBranch.Selected.Value = "AirForce", LookUp(StockImages, Title = VBranch.Selected.Value, Photo).Large,
    VBranch.Selected.Value = "Navy", LookUp(StockImages, Title = VBranch.Selected.Value, Photo).Large)

    Thanks to everyone that assisted me.
  • WarrenBelz Profile Picture
    153,084 Most Valuable Professional on at
    If what you have posted works, all you need is this
    If(
       VBranch.Selected.Value in ["Army", "Navy", "Airforce"],	  
       LookUp(
          StockImages, 
          Title = VBranch.Selected.Value 
       ).Photo.Large
    )
    or actually, you do not really need the top test unless there is another selection you do not want to display.
    LookUp(
       StockImages, 
       Title = VBranch.Selected.Value 
    ).Photo.Large
     
    Please ✅ Does this answer your question 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 a Like♥.
    Visit my blog Practical Power Apps    LinkedIn   

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard