Forum Discussion
288088
Nov 05, 2019Brass Contributor
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 m...
- Nov 08, 2019
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" } ] }
Matti Paukkonen
Nov 08, 2019Iron Contributor
288088, you can save the formatting without errors?
For me, my example works correctly:
Can you send me your version as an attachment? I can check it out.
288088
Nov 08, 2019Brass Contributor
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"
}
]
}