Color Coding Sharepoint list (conditional formating)

SOE_Tech 0 Reputation points
2023-08-02T08:03:40.2633333+00:00

Hello everyone,

i created a list in Sharepoint for some invoices with three dates:

  • Checked
  • Booked
  • Paid

I would now like to have the colored condition:

If the date in checked is older then 3 days AND there is no date in Booked mark "checked" red

If someone could help me with that id appreciate it

Microsoft 365 and Office | SharePoint | For business | Windows
{count} votes

2 answers

Sort by: Most helpful
  1. SOE_Tech 0 Reputation points
    2023-08-03T05:39:13.0266667+00:00

    So i gotten to the point where it works for one column but not he next one...

    This one is for the colum "Genehmigung" and works as inteded if it is standalone:

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "div",
      "txtContent": "@currentField",
      "style": {
        "font-weight": "=if(@currentField <= @now - 518400000, 'bold', if(@currentField <= @now - 259200000, 'semi-bold', 'normal'))",
        "background-color": "=if([$GebuchtSEN] != '', 'transparent', if(@currentField <= @now - 518400000, 'red', if(@currentField <= @now - 259200000, 'orange', 'green')))",
        "padding-left": "14px"
      }
    }
    

    This one is for the column "Booked" and should, if a value in "Paid" (here BezahltSEN) is added not meet the condition. but when i enter the code the background remains red/orange/green. If i then delete the entry in "BezahltSEN" the background remains - and in a new entry neither coloring works suddenly

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "div",
      "txtContent": "@currentField",
      "style": {
        "font-weight": "=if(@currentField <= @now - 518400000, 'bold', if(@currentField <= @now - 259200000, 'semi-bold', 'normal'))",
        "background-color": "=if([$BezahltSEN] != '', 'transparent', if(@currentField <= @now - 518400000, 'red', if(@currentField <= @now - 259200000, 'orange', 'green')))",
        "padding-left": "14px"
      }
    }
    
    0 comments No comments

  2. Yanli Jiang - MSFT 31,666 Reputation points Microsoft External Staff
    2023-08-08T09:50:06.9333333+00:00

    Hi SOE_Tech ,

    I have tested in my site, below is my test:

    For Checked column:

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "div",
      "txtContent": "@currentField",
      "style": {
        "font-weight": "=if(@currentField <= @now - 518400000, 'bold', if(@currentField <= @now - 259200000, 'semi-bold', 'normal'))",
        "background-color": "=if(Number([$Booked]) != 0, 'transparent', if(@currentField <= @now - 518400000, 'red', if(@currentField <= @now - 259200000, 'orange', 'green')))",
        "padding-left": "14px"
      }
    }
    

    User's image

    For Booked column:

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "div",
      "txtContent": "@currentField",
      "style": {
        "font-weight": "=if(@currentField <= @now - 518400000, 'bold', if(@currentField <= @now - 259200000, 'semi-bold', 'normal'))",
        "background-color": "=if(Number([$Paid]) != 0, 'transparent', if(@currentField <= @now - 518400000, 'red', if(@currentField <= @now - 259200000, 'orange', 'green')))",
        "padding-left": "14px"
      }
    }
    

    User's image

    The code can work well in my list. You can give a try.

    Hope this helps.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.