cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
GingerOfTech
New Member

Conditional Fill Color Based on Selection

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!

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@GingerOfTech 

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.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

7 REPLIES 7
RandyHayes
Super User III
Super User III

@GingerOfTech 

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. 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

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.

RandyHayes
Super User III
Super User III

@GingerOfTech 

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?

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

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"

RandyHayes
Super User III
Super User III

@GingerOfTech 

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.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

Exactly what I was needing, thanks for all your help!

RandyHayes
Super User III
Super User III

@GingerOfTech 

Happy to help.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (42,891)