I apologize for beating a dead horse. I have visited all the possible forum posts in regards to conditional formatting to adjust a fill color but can't seem to find one in the same scenario.
What I am attempting to do: In a PowerApp from a SP list is to use the value from a single choice dropdown where the choices are "Completed" "Scheduled" and "UnScheduled"
My rudimentary code in the Fill is as follows:
If('Final Photos Status_DataCard3'="Completed",Green, If('Final Photos Status_DataCard3'="UnScheduled",Red, If('Final Photos Status_DataCard3'="Scheduled",Yellow)))
I have a two fold issues which is I believe this is an invalid argument but being as it has been quite a while since I have coded anything like this I know I am just missing something. I also am getting the "PowerApps encountered an error while trying to evaluate this expression. Data Type: Control" message which I have been unable to resolve as of yet.
Any insight from this community would be greatly appreciated!
Solved! Go to Solution.
Very good. Then your formula should be this:
Switch(ThisItem.'Final Photos Status'.Value,
"Completed", Green,
"UnScheduled", Red,
"Scheduled", Yellow
)
In the Gallery, you want to refer to the row values - this is in the ThisItem statement. So, in the above we are looking at the row item (ThisItem) for the 'Final Photos Status' column and the value in that column.
Please consider changing your Formula to the following:
Switch('Final Photos Status_DataCard3'.Selected.Value,
"Completed", Green,
"UnScheduled", Red,
"Scheduled", Yellow
)
I hope this is helpful for you.
This is excellent, a much cleaner solution than I had originally been attempting. I have a remaining issue as I tried to place this exactly it came back with the error "Name isn't valid, this identified isn't recognized" however I have confirmed that the Card is still identified in PowerApps as 'Final Photos Status_DataCard 3' I altered the code to look at 'datacardvalue24' which holds the photo status in detail view and that works, however it changes all the entries to match the status of the first in the list.
So to get this to work, you need to reference the proper property value of the control.
I have assumed that you have a Dropdown control in your Datacard. However I missed that you were not referring to the control properly.
So I need some more information from you.
What control are you trying to set the Fill on? Is the control in your Gallery or in your Form (I am starting to lean toward, from your reply, that this is in a Gallery)?
And finally, what is the name of the Column in your datasource that is the Choice column?
Apologies, you are correct that it is in gallery. The goal is for the fill behind the title of each entry to reflect it's status. The name of the column in the datasource (my SP list) is "Final Photos Status"
Very good. Then your formula should be this:
Switch(ThisItem.'Final Photos Status'.Value,
"Completed", Green,
"UnScheduled", Red,
"Scheduled", Yellow
)
In the Gallery, you want to refer to the row values - this is in the ThisItem statement. So, in the above we are looking at the row item (ThisItem) for the 'Final Photos Status' column and the value in that column.
Exactly what I was needing, thanks for all your help!
Happy to help.
How to use switch function if based on number entry of user in DataCard1?
red if >2
amber = 1
green = 0
I used this it worked.
Switch(DataCardValue1.Text, "1", Yellow, "0", Green, Red)
User | Count |
---|---|
253 | |
122 | |
106 | |
54 | |
48 |