Hi Guys, i need help in formatting a columns in sharepoint with colour options

Anonymous
2022-04-11T14:25:42.107+00:00

Hi Guys, i need help in formatting a columns in sharepoint with colour options

Let say, I have Forecast Begin Date which should show with priority.

If Forecast Begin Date is within 7 days it should show in red colour
If Forecast Begin Date is within 8-15 days it should show in orange colour
If Forecast Begin Date is within 16-30 days it should show in yellow colour
And Forecast Begin Date is more than 30 days it should show in green colour

Also if Forecast Begin Date has crossed it should not have any colour.

Thanks\

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,603 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,663 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,572 questions
0 comments No comments
{count} votes

Accepted answer
  1. Emily Du-MSFT 41,771 Reputation points Microsoft Vendor
    2022-04-12T07:57:55.767+00:00

    @Anonymous

    You could use following JSON formatting formula for the Forecast Begin Date column.

    {  
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",  
      "elmType": "div",  
      "txtContent": "@currentField",  
      "style": {  
        "color": "black",  
        "background-color": "=if(@currentField>@now + 2592000000,'green', if((@currentField>=@now + 1382400000) && (@currentField<@now + 2592000000) , 'yellow',if((@currentField>=@now + 691200000) && (@currentField<@now + 1296000000), 'orange', if((@currentField>=@now + 0) && (@currentField<@now + 604800000),'red',' '))))"  
      }  
    }  
    

    Result:
    192179-image.png


    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.


0 additional answers

Sort by: Most helpful