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?
Solved! Go to Solution.
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.
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.
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:
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) )
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:
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
, 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!
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.
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.
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.
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:
That one row with the 3 in it (or whatever quantity you picked) should be LightGreen...is it?
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.
Check it out!
Check it out!
Fill out a quick form to claim your user group badge now!
Find out where you can attend!
Features releasing from October 2019 through March 2020
The largest Power BI, Power Platform, and Data conference in New Zealand