0

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?

1
  • I found this and hoped it would help me ... I have never used JSON code before. I also had a calculated column with the result of Open or Closed. I copied the code and pasted it to my column formatting section. I couldn't see that it needed me to reference my column name so made no changes to the code. But on saving and viewing my list I got an error message in the column. What am I doing wrong? See image: ![enter image description here](i.stack.imgur.com/1KpDt.png) – user94456 Jan 14 at 7:45
2

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:

enter image description here

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:

enter image description here

1
  • Extremely helpful once again, thank you – Andrea Feb 11 '20 at 10:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.