Forum Discussion
Need help with formating colors based on time in columns
Hello!
Need some help with formating columns based on what time they got, if its more or less, then I want it to change color. See pictures.
Sorry for my bad english, hope you guys can help me anyway 🙂
I managed with another code to get the result that I wanted, but thanks for the effort!
{ "$schema": "<a href="https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json" target="_blank">https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json</a>", "elmType": "div", "attributes": { "class": "=if(@currentField <= '02:00:00', 'sp-field-severity--good', if(@currentField >= '02:00:00', 'sp-field-severity--blocked', '" }, "children": [ { "elmType": "span", "style": { "display": "inline-block", "padding": "0 4px" }, "attributes": { "iconName": "=if(@currentField <= '02:00:00', 'CheckMark', if(@currentField >= '02:00:00', 'Warning', '" } }, { "elmType": "span", "txtContent": "@currentField" } ] }
19 Replies
- Lenamuhax1Copper Contributor
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"style": {
"background-color": "=if(@currentField == 'Completed', 'green', if(@currentField == 'Pending', 'yellow', 'transparent'))",
"color": "white",
"padding": "5px",
"border-radius": "3px",
"text-align": "center"
},
"txtContent": "@currentField"
} Good Afternoon I hope you doing well. Just I need help for this Code in SharePoint. So I want to create background color columns . I used this code but it does not work with me. Can you help me plz - Matti PaukkonenIron Contributor
- 288088Brass Contributor
Matti Paukkonen Hello! Those columns are "Calculated" Values
15min has formula:
=TEXT([Assigned technicians]-[case received];"h:mm:ss")
Response time has formula:
=TEXT(Started-[case received];"h:mm:ss")
- Matti PaukkonenIron Contributor
Here is an example for 15min column, just replace the field references with your fields and add $schema reference in the beginning (editor messes up the links 😞 )
{ "elmType": "div", "attributes": { "class": {"operator":"?", "operands":[ {"operator":"<","operands":[ "[$assigned]", { "operator": "+", "operands": [ "[$case]", 900000 ] }]},"sp-field-severity--good","" ]} }, "children": [ { "elmType": "span", "style": { "display": "inline-block", "padding": "0 4px" }, "attributes": { "iconName": {"operator":"?", "operands":[ {"operator":"<","operands":[ "[$assigned]", { "operator": "+", "operands": [ "[$case]", 900000 ] }]},"CheckMark","" ]} } }, { "elmType": "span", "txtContent": "@currentField" } ] }