2

I'm looking to color code the Modified column in Microsoft Lists. I know I need to use JSON but unsure of the code.

I would like it to be green if less than or equal to 30 days, orange/Amber if between 31 and 45, and red if greater than 45.

Any help would be massively appreciated!

1 Answer 1

1

Try using JSON column formatting for Modified column with this JSON:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "style": {
    "color": "=if(@currentField < addDays(@now,-45), 'red', if(@currentField < addDays(@now,-30),'orange','green'))"
  },
  "txtContent": "=@currentField"
}

Output:

enter image description here

You can change the style as per your requirements based on similar conditions given in above JSON.

Example:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "style": {
    "color": "white",
    "background-color": "=if(@currentField < addDays(@now,-45), 'red', if(@currentField < addDays(@now,-30),'orange','green'))",
    "font-weight": "bold",
    "padding-left": "10px"
  },
  "txtContent": "=@currentField"
}

Output:

enter image description here

Documentation: Use column formatting to customize SharePoint

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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