Status calculated column colour code
Pregunta
I have a calculated column with this below formula:
=IF(ISBLANK([Confirmed Receipt Date]),"Open","Closed")
How do I make Open with red color and Closed a green color?
Solución
You can use Column/JSON formatting to achieve this. Use below JSON code to change the color of the text:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"debugMode": true,
"txtContent": "@currentField",
"style": {
"color": "=if(@currentField == 'Open', '#ff0000', '#00ff00')"
}
}
Output:
Documentation: Use column formatting to customize SharePoint.
Additional:
If you want to change the background color with some cool icons then try below JSON code:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"attributes": {
"class": "=if(@currentField == 'Close', 'sp-field-severity--good', 'sp-field-severity--blocked') + ' ms-fontColor-neutralSecondary'"
},
"children": [
{
"elmType": "span",
"style": {
"display": "inline-block",
"padding": "0 8px"
},
"attributes": {
"iconName": "=if(@currentField == 'Close', 'CheckMark', 'ErrorBadge')"
}
},
{
"elmType": "span",
"txtContent": "@currentField"
}
]
}
It will look like this:
Licenciado bajo: CC-BY-SA con atribución
No afiliado a sharepoint.stackexchange