cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Salamander94
Helper IV
Helper IV

Make the Browse Screen Change Colors Depending on field

So I am creating an inventory app.  I want the browse screen to display items in a seperate color (or atleast the text) based on how much of that item is left. 

Basically if there's only 1 monitor left in our inventory I want that section to be highleted in red so I know to order more.  I also don't need it to do this for every item.  Just specific ones.  Is this possible?   I keep trying things like:

If(Quantity <= 3, RGBA(100,0,0,0), RGBA(0,0,0,0))

Obviously with different "RGBA", but you get the gist.  Is this even possible?  If not any cool suggestions?

1 ACCEPTED SOLUTION

Accepted Solutions

@Salamander94 

Ah ha...now we see the issue.  PowerApps sees your Quantity column as a text column.

So, change your TemplateFill to the following:

If(Value(ThisItem.Quantity) <= 1, DeepPink, 
   Value(ThisItem.Quantity) <= 3, LightSalmon, 
   Value(ThisItem.Quantity) <= 10, LightSkyBlue, 
   LightGreen
)

And now you should see some colors!

 

Since you pulled this from Excel, you might want to double back on the Excel file and look at the formatting for the Quantity column.  Something is confusing PowerApps to think it is a text column.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

13 REPLIES 13
RandyHayes
Super User
Super User

@Salamander94 

Yes, this is all quite possible.  

If you are looking at changing the color on text on Labels, look at the Color property on them.  There you can add the formula you had to make the colors changed based on conditions.

Have you tried any of that and run into issues?

Also, you can certainly use the RGBA function to create colors, but you can also use the names of the colors if that becomes easier for you to read.

If(Quantity <= 3, Red, Black)

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
v-xida-msft
Community Support
Community Support

Hi @Salamander94 ,

How do you list your inventory items within your app? Using a Gallery?

Do you want to render the Gallery Items in different color based on the Quantity column value?

 

Based on the needs that you mentioned, I assume that you use a Gallery within your app to list your Inventory items, is it true?

I have made a test on my side, I think the If function could achieve your needs. I have made a test on my side, please consider take a try with the following workaround:10.JPG

 

11.JPG

Set the TemplateFill property of the Gallery to following:

If(
    ThisItem.Quantity <= 1, RGBA( 255, 20, 147, 1 ), 
    ThisItem.Quantity <= 3, RGBA( 255, 160, 122, 1),
    ThisItem.Quantity <= 10, RGBA( 135, 206, 250, 1),
    ThisItem.Quantity > 10, RGBA( 144, 238, 144, 1 )
)

On your side, you should type the following formula:

If(
    ThisItem.Quantity <= 1, 
RGBA(100, 0, 0, 1), /* <-- The last argument of the RGBA() function here should be 1 rather than 0 */
RGBA(0, 0, 0, 0) )

12.JPG

Note: If you want to display a color using RGBA() function, the last argument should be 1 rather than 0, otherwise, the corresponding color would not be displayed. The last argument of RGBA() function represents the Alpha value, 1 represents the fully opaque, 0 represents the fully transparent.

More details about the RGBA() function, please check the following article:

RGBA() function

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I tried this and it didn't work unfortunetely.  Although I'm sure I'm doing something wrong.  I selected the browse gallerey and enterened in this for the template fill:

If(ThisItem.Quantity <= 1, RGBA(255, 20, 147,1), ThisItem.Quantity <= 3, RGBA(255, 160, 122, 1), ThisItem.Quantity <= 10, RGBA(135,206,250,1), ThisItem.Quantity > 10, RGBA(144,238,144,1))

That didn't change anything.  I wasn't so sure where to put the second line of code you provided so I selected the browse screen and for the "fill" area I started to try and enter

If(ThisItem.Quantity

, but it would't recognize the field.  I'm assuming I'm entering it into the wrong place?  Also, I do have a search bar and what not so my "item" code area looks like this:

SortByColumns(Search(items1, TextSearchBox1_1.Text,"Item","Location","Make","Title"), "Title", If(SortDescending1, Descending, Ascending))

Thanks for all your help!

@Salamander94 

 

Adjusting the TemplateFill on the Gallery will alter the background color of an individual row based on your formula.  Changing the Fill property of the Gallery will alter the background color of the entire Gallery.

 

So, in your case, if you're trying to change the background color of the row based on the value, then you will want to change the TemplateFill property on the Gallery.

Using your existing formula (with the color names used rather than the RGBA values - for clarity) and a slight change to the final "else" part of the formula, try this in your Gallery's TemplateFill property.

If(ThisItem.Quantity <= 1, DeepPink, 
   ThisItem.Quantity <= 3, LightSalmon, 
   ThisItem.Quantity <= 10, LightSkyBlue, 
   LightGreen
)

If that does not provide any results, then we should look at your Quantity and make sure you are actually getting a number there you expect.  With the above formula you *should* see colors...at least DeepPink or LightGreen.

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Well hello again Randy!  You've helped me before and I wanted to take a minute to say thanks in case I didn't last time.  At any rate this did not work for me.  It didn't change any colors.  I did use it in the gallery's template fill section.  Just in case you need to know the data is coming from an excel document on one drive.  Let me know what other information you need.


 

@Salamander94 

No problem...happy to help.

So this seems a little unusual.  Let's take a couple of steps to troubleshoot:

1) Change your TemplateFill property to : LightGreen - you should see all the items in LightGreen background.  Do you?

2) Do you have a label in your Gallery for the Quantity?  If so, what does it show on a couple - are they valid numbers?  If you don't have a quantity label, put a label in your Gallery and set the Text property to ThisItem.Quantity - does it show a proper number?

 

Let's start with that and see what you get.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Yes, using just "light green" works.  Yes I do have a label for the quantity.  It is set as "ThisItem.Quantity"

@Salamander94 

Okay...that is good.  We're making progress.

Now, look at one of your list items and its Quantity value (let's say it says 3).

Change your TemplateFill property to the following:

If(ThisItem.Quantity=3, LightGreen)

That one row with the 3 in it (or whatever quantity you picked) should be LightGreen...is it?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

This did work, but I had to use quotation marks around the 3. 

If(ThisItem.Quantity = "3", LightGreen)

It didn't work without them.  I also tried using "<=" instead of "=" but that didn't work.

Helpful resources

Announcements

Power Platform Connections - Episode 7 | March 30, 2023

Episode Seven of Power Platform Connections sees David Warner and Hugo Bernier talk to Dian Taylor, alongside the latest news, product reviews, and community blogs.     Use the hashtag #PowerPlatformConnects on social media for a chance to have your work featured on the show.     

Announcing | Super Users - 2023 Season 1

Super Users – 2023 Season 1    We are excited to kick off the Power Users Super User Program for 2023 - Season 1.  The Power Platform Super Users have done an amazing job in keeping the Power Platform communities helpful, accurate and responsive. We would like to send these amazing folks a big THANK YOU for their efforts.      Super User Season 1 | Contributions July 1, 2022 – December 31, 2022  Super User Season 2 | Contributions January 1, 2023 – June 30, 2023    Curious what a Super User is? Super Users are especially active community members who are eager to help others with their community questions. There are 2 Super User seasons in a year, and we monitor the community for new potential Super Users at the end of each season. Super Users are recognized in the community with both a rank name and icon next to their username, and a seasonal badge on their profile.    Power Apps  Power Automate  Power Virtual Agents  Power Pages  Pstork1*  Pstork1*  Pstork1*  OliverRodrigues  BCBuizer  Expiscornovus*  Expiscornovus*  ragavanrajan  AhmedSalih  grantjenkins  renatoromao    Mira_Ghaly*  Mira_Ghaly*      Sundeep_Malik*  Sundeep_Malik*      SudeepGhatakNZ*  SudeepGhatakNZ*      StretchFredrik*  StretchFredrik*      365-Assist*  365-Assist*      cha_cha  ekarim2020      timl  Hardesh15      iAm_ManCat  annajhaveri      SebS  Rhiassuring      LaurensM  abm      TheRobRush  Ankesh_49      WiZey  lbendlin      Nogueira1306  Kaif_Siddique      victorcp  RobElliott      dpoggemann  srduval      SBax  CFernandes      Roverandom  schwibach      Akser  CraigStewart      PowerRanger  MichaelAnnis      subsguts  David_MA      EricRegnier  edgonzales      zmansuri  GeorgiosG      ChrisPiasecki  ryule      AmDev  fchopo      phipps0218  tom_riha      theapurva  takolota     Akash17  momlo     BCLS776  Shuvam-rpa     rampprakash  ScottShearer     Rusk  ChristianAbata     cchannon  Koen5     a33ik   Heartholme     AaronKnox        Matren        Alex_10        Jeff_Thorpe        poweractivate        Ramole        DianaBirkelbach        DavidZoon        AJ_Z        PriyankaGeethik        BrianS        StalinPonnusamy        HamidBee        CNT        Anonymous_Hippo        Anchov        KeithAtherton        alaabitar        Tolu_Victor        KRider        sperry1625        IPC_ahaas      zuurg    rubin_boer   cwebb365   Dorrinda   G1124   Gabibalaban   Manan-Malhotra   jcfDaniel   WarrenBelz   Waegemma      If an * is at the end of a user's name this means they are a Multi Super User, in more than one community. Please note this is not the final list, as we are pending a few acceptances.  Once they are received the list will be updated. 

Microsoft Power Platform Conference | Registration Open | Oct. 3-5 2023

We are so excited to see you for the Microsoft Power Platform Conference in Las Vegas October 3-5 2023! But first, let's take a look back at some fun moments and the best community in tech from MPPC 2022 in Orlando, Florida.   Featuring guest speakers such as Charles Lamanna, Heather Cook, Julie Strauss, Nirav Shah, Ryan Cunningham, Sangya Singh, Stephen Siciliano, Hugo Bernier and many more.   Register today: https://www.powerplatformconf.com/   

Check out the new Power Platform Communities Front Door Experience!

We are excited to share the ‘Power Platform Communities Front Door’ experience with you!   Front Door brings together content from all the Power Platform communities into a single place for our community members, customers and low-code, no-code enthusiasts to learn, share and engage with peers, advocates, community program managers and our product team members. There are a host of features and new capabilities now available on Power Platform Communities Front Door to make content more discoverable for all power product community users which includes ForumsUser GroupsEventsCommunity highlightsCommunity by numbersLinks to all communities Users can see top discussions from across all the Power Platform communities and easily navigate to the latest or trending posts for further interaction. Additionally, they can filter to individual products as well.       Users can filter and browse the user group events from all power platform products with feature parity to existing community user group experience and added filtering capabilities.     Users can now explore user groups on the Power Platform Front Door landing page with capability to view all products in Power Platform.    Explore Power Platform Communities Front Door today. Visit Power Platform Community Front door to easily navigate to the different product communities, view a roll up of user groups, events and forums.

Welcome to the Power Apps Community

Welcome! Congratulations on joining the Microsoft Power Apps community! You are now a part of a vibrant group of peers and industry experts who are here to network, share knowledge, and even have a little fun! Now that you are a member, you can enjoy the following resources:   The Microsoft Power Apps Community Forums If you are looking for support with any part of Microsoft Power Apps, our forums are the place to go. They are titled "Get Help with Microsoft Power Apps " and there you will find thousands of technical professionals with years of experience who are ready and eager to answer your questions. You now have the ability to post, reply and give "kudos" on the Power Apps community forums! Make sure you conduct a quick search before creating a new post because your question may have already been asked and answered!   Microsoft Power Apps IdeasDo you have an idea to improve the Microsoft Power Apps experience, or a feature request for future product updates? Then the "Power Apps Ideas" section is where you can contribute your suggestions and vote for ideas posted by other community members. We constantly look to the most voted Ideas when planning updates, so your suggestions and votes will always make a difference.   Community Blog & NewsOver the years, more than 600 Power Apps Community Blog Articles have been written and published by our thriving community. Our community members have learned some excellent tips and have keen insights on building Power Apps. On the Power Apps Community Blog, read the latest Power Apps related posts from our community blog authors around the world. Let us know if you would like to become an author and contribute your own writing — everything Power Apps related is welcome!   Power Apps Samples, Learning and Videos GalleriesOur galleries have a little bit of everything to do with Power Apps. Our galleries are great for finding inspiration for your next app or component. You can view, comment and kudo the apps and component gallery to see what others have created! Or share Power Apps that you have created with other Power Apps enthusiasts. Along with all of that awesome content, there is the Power Apps Community Video & MBAS gallery where you can watch tutorials and demos by Microsoft staff, partners, and community gurus in our community video gallery.   Again, we are excited to welcome you to the Microsoft Power Apps community family! Whether you are brand new to the world of process automation or you are a seasoned Power Apps veteran. Our goal is to shape the community to be your ‘go to’ for support, networking, education, inspiration and encouragement as we enjoy this adventure together!   Let us know in the Community Feedback if you have any questions or comments about your community experience.To learn more about the community and your account be sure to visit our Community Support Area boards to learn more! We look forward to seeing you in the Power Apps Community!The Power Apps Team

Top Solution Authors
Top Kudoed Authors
Users online (4,644)