0

I am reading data about countries from Excel online to my Power Apps application. There is a column in excel is called countryImage and has a string for example "UK". I have uploaded all the country images in the library in Power Apps and they are named as country (UK.svg, US.svg).

I am displaying the Excel online table using TemplateGallery in Power Apps and one of the fields is an image. In that field for the variable image I have written "ThisItem.countryImage" and it is displaying blank. However if I write just "UK", the image is displayed. Why is this so and how can I dynamically display the image as countryImage field for each row?

Thank you.

5
  • how many country records are there in excel and how many image files you have uploaded to app? Jul 18, 2023 at 15:21
  • There are more country records than images (some appear more times), but there is an image for each country in the app library.
    – pomaaa
    Jul 19, 2023 at 9:00
  • How many Country records? You Can write Swich function based on country data to pass image name to image control. Jul 19, 2023 at 10:06
  • There will be around 40 countries
    – pomaaa
    Jul 19, 2023 at 13:53
  • Ok. check my answer given below. You will have to use switch function and provide image name based on country name for each country. let me know if you face any issues while using it or if it works for you. Jul 19, 2023 at 13:59

1 Answer 1

1

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

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

Switch(
    ThisItem.countryImage,
    "UK",
    UK,
    "US",
    US,
    "India",
    India,
    DefaultCountryImg
)

Where country names enclosed in double quotes (like "US") should match with values from your excel column.

And country names without double quotes are your image names. You might need to enclose those in single quotes based on your image file names, like 'South-Africa'.

Also, DefaultCountryImg is the name of any image you want to show in case country does not have image in your app.

Documentation: If and Switch functions in Power Apps

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.