Forum Discussion

SarahC690's avatar
SarahC690
Copper Contributor
Oct 07, 2024

Conditional Formatting - Sharepoint List

It has been a while since using sharepoint lists and I am a bit out of practice!

 

I have set up a list which shows a list of Assessments which each staff member needs to complete and the date it expires. Not everyone has to do the same assessments. 

 

I need to add to add conditional formatting into a date column to do the following:

 

If the cell is blank for it to be shaded grey.

If the date has expired the for it to be shaded red (the light coloured red)

If the date has not expired for it to be coloured green (the light green).

 

Any help much appreciated.

 

1 Reply

  • Rob_Elliott's avatar
    Rob_Elliott
    Silver Contributor

    SarahC690 you would format the date column in advanced mode, deleting whatever's there and paste in the following:

     

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
      "elmType": "div",
      "txtContent": "@currentField",
      "style": {
        "background-color": "=if(Number(@currentField) == 0, 'gray', if(@currentField >= @now, 'green', '#fb6767'))",
        "color": "white",
        "padding-left": "4px"
      }
    }

     

     

     

    Rob
    Los Gallardos
    Microsoft Power Automate Community Super User.
    Principal Consultant, SharePoint and Power Platform WSP Global (and classic 1967 Morris Traveller driver)

Resources