Forum Discussion
List format question, with an either/or scenario
- Aug 05, 2020
alandarr just looking at your question 1 for the moment you can do this with the following JSON column formatting. In this example if the value you enter is less than or equal to 10% then it puts the background green, if it's between 11 and 50% then it's orange, otherwise it's dark red:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json", "elmType": "div", "txtContent": "=toString(@currentField * 100) + '%'", "style": { "border": "none", "padding-left": "14px", "background-color": "=if(@currentField <= 0.1,'#468259', if(@currentField > 0.1 && @currentField <= 0.5,'#d8a810', '#c00000'))", "color": "white" } }Which gives the following result:
I hope that gives you what you need.
Rob
Los Gallardos
Microsoft Power Automate Community Super User.
If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks.
alandarr the JSON for your second question is more simple. In this example if the user enters the text Chris then the background is green, otherwise it's red:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"border": "none",
"padding-left": "14px",
"background-color": "=if(@currentField == 'Chris', '#468259', '#c00000')",
"color": "white"
}
}
and the result is:
Rob
Los Gallardos
Microsoft Power Automate Community Super User.
If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks.
- alandarrAug 07, 2020Brass ContributorRob Elliott
Again, many thanks. Your answer to my second question is spot on!
I could not survive without this community!