1

I have an app that I have uploaded several small images into. What I am trying to accomplish is by use of a drop down with the selection option of we will say:

  • Cat
  • Dog
  • Turtle

I would like with the image component to reference my media files and display the image associated with the selection.

When I do it manually, It works with the input of 'Dog' and displays as an image data type with the proper image displayed, but if I use the formula of "'" & animalDD.SelectedText.Value & "'", it displays the same, 'Dog' in the compile window, but as a text data type with no image shown.

How can I get this to reference with the image dynamically with the drop down?

1
  • On which control did you apply your formula?
    – jleture
    Commented Nov 19, 2023 at 8:14

1 Answer 1

0

Image control is displaying blank because your are passing animalDD.SelectedText.Value (which is of type text/string) to Image property.

Instead of it, try using Switch function like below for Image property:

Switch(
    animalDD.SelectedText.Value,
    "Cat",
    Cat,
    "Dog",
    Dog,
    "Turtle",
    Turtle,
    DefaultAnimalImg
)

If above formula does not work for you, try using animalDD.Selected.Value instead of animalDD.SelectedText.Value assuming you are using single selection drop down control.

Where animal names enclosed in double quotes (like "Cat") should match with values from your drop down options.

And animal names without double quotes are your image names. You might need to enclose those in single quotes based on your image file names, like 'Polar-Bear', Turtle, etc.

Also, DefaultAnimalImg is the name of any image you want to show in case animal name from drop down does not have image in your app.

Documentation: If and Switch functions in Power Apps

Similar thread: Dynamically displaying images in Power Apps Gallery

2
  • I appreciate your response, however the switch function defeats the purpose as my dropdown selection is large. I already have the images labeled as the same name that is available in the dropdown so I was hoping to just reference that to save on some coding. I did try the selected.value method but still receive the text output instead of the image of the same name
    – Kody
    Commented Nov 20, 2023 at 22:01
  • I understand what you are saying. But unfortunately this is a limitation of Power Apps which cannot convert your text output to image/media file name. That's why you will have to use the Switch or related functions in Power Apps. Commented Nov 21, 2023 at 5:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.