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 / How to Toggle the colo...
Power Apps
Answered

How to Toggle the color of an icon based on a column value.

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

 

Hello fellow Power Appers,

 

I am having trouble toggling the color of an icon based on a "true/false" text value in a data column.

 

My Sharepoint list, 'Progress Note Data' contains a text Column 'IsApproved' "true/false" (as string). I would like to read the value and set the color of an icon based on that value.

 

If the icon is clicked(OnSelect) I would like the color to toggle between Green and Red.

 

The icon is in a gallery, ideally I would like to reference the ID of the icon(s) in the gallery, or use ThisItem.ID?  I have tried for several hours to make this work but I must be missing some key detail.


Any help given would be appreciated. 

 

Thank you.

Categories:
  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @Anonymous Is the data source for the gallery where the icon is 'Progress Note Data'?

    You have mentioned 2 thing,

    1. I would like to read the value and set the color of an icon based on that value.

    2. If the icon is clicked(OnSelect) I would like the color to toggle between Green and Red.

    So you want the color based on the value in 'IsApproved' or it has to change on click? Kindly clarify. 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi CNT, 

     

    Yes, the gallery data source is 'Progress Note Data'.

     

    To clarify the second point.. Ideally the OnSelect event would cause the 'IsApproved' value to toggle between "true/false" for that specific row.. which would toggle the color of the icon.

     

    Thank you again for the help!

  • Verified answer
    CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @Anonymous Set the Fill Property of the icon to, 

    If(ThisItem. 'IsApproved'="true", Green, Red)

    This will change the colour of the icon to Green/Red when  'IsApproved' is "true"/"false"

    Hope this helps!

     

    Please remember to give a 👍 and accept the solution as it will help others in the future.

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi CNT,

     

    I did use your code, additionally I used:

     

    If(ThisItem.Approved = "true", Patch('Progress Data List', ThisItem, {Approved: "false"}), Patch('Progress Data List', ThisItem,{Approved: "true"}));

     

    I am sure there are better ways to write this code, but it does manage to toggle the table column text value which is what I was after.

     

    Thank you very much for your help.

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @Anonymous Glad to help!

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 381 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 340

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard