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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Conditionally show ima...
Power Apps
Answered

Conditionally show images based on Text column

(0) ShareShare
ReportReport
Posted on by 116

Hi,

 

I'm not sure if what I'm trying to do will work.

 

I'm creating a gallery based on a sharepoint list.  I have 4 images saved in media and I'd like to conditionally set which image is displayed based on a text field in my sharepoint list.

 

This is what I tried just to toggle between 2 of the 4 colors, but it's looking for a boolean.  

 

 

If(nDirectorate = "OD",CONTENTbox_blue,CONTENTbox_yellow)

 

 

Is there a way around this?  I'm basically trying to color code my results based on which directorate the employee is associated with.

 

Thank you!

Categories:
I have the same question (0)
  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    Hi @aharsh 

     

    Can you share more details about the app configuration? Where is this nDirectorate coming from? 

     

    The expression seems to be right if nDirectorate  is a variable storing the appropriate value. If you could share more details, we might be able to help you better. I am assuming that you have placed the expression on the Image property of the control.

     

    Also, are you getting any errors?

     

    Hope this Helps!

     

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

  • aharsh Profile Picture
    116 on at

    Hi, @yashag2255  thank you for taking time to respond.  Not sure what other details will help.

     

    I have a sharepoint list and I've created a Powerapps gallery that links to it. 

     

    One of my columns is nDirectorate, which is a choice column. The 4 choices are - OD, HRD, FMD, AQD.

     

    I've uploaded 4 images to media, CONTENTbox_purple, CONTENTbox_blue, CONTENTbox_teal, CONTENTbox_yellow

     

    I set this code in the Image control for the Gallery, and I'm getting an error. I get a red line under the = and it says invalid argument type.

     

    If(nDirectorate = "OD",CONTENTbox_blue,CONTENTbox_yellow)

     

    Please let me know if those details help and what other details I may provide.

  • Verified answer
    yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    Hi @aharsh 

     

    Since the column is a choice type column, the formula should be:

    If(nDirectorate.Value = "OD",CONTENTbox_blue,CONTENTbox_yellow)

     

    Hope this Helps!

     

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

  • aharsh Profile Picture
    116 on at

    Thank you, @yashag2255  - Now I'm seeing both blue and yellow boxes - Hooray!  That was the first step of my work

     

    Now, I just need to figure out how to show the other two colors based on the other two choices 😕

     

     

  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    @aharsh 

     

    To add multiple conditions, you can use the expression as:

    If(nDirectorate.Value = "OD",CONTENTbox_blue,nDirectorate.Value = "Value2",CONTENTbox_yellow,nDirectorate.Value = "Value3",CONTENTbox_green,CONTENTbox_red)

     

    Hope this Helps!

     

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 324 Most Valuable Professional

#2
11manish Profile Picture

11manish 193

#3
Valantis Profile Picture

Valantis 138

Last 30 days Overall leaderboard