Forum Discussion

Chonski55's avatar
Chonski55
Copper Contributor
Nov 22, 2023

Conditionnal formating based on empty (or not) fields

Hi,

I have 3 columns of data : Status, Owner, Date.

I'd like to have the sharepoint view (not column formatting) to show the lines in my list in :

- RED if none of the fields has info in it

- Orange if Status and Owner has info in it and Date is empty

- Gray if all of them contain info (not empty)

 

I have tried going through the sharepoint list condtitionnal formating view but the only rules we can set up in place is based on the "equal"/"not equal" to a specific value in the field. Given that my status field has more than 10 different statuses, it's quite complicated to work this way (same for owner field that might have more than 1000 different values).

 

I was wondering if the format view can be done based on empty/not empty rather than based on specific values?

 

Thanks

5 Replies

  • Chonski55 

     

    If Status is single selection choice column, Owner is single selection person or group column and "Date is a Date & Time column, you can use JSON view formatting like below in "Advanced mode": 

     

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
      "additionalRowClass": "=if([$Status]=='' && Number([$DueDate])==0 && [$Owner.title]=='', 'ms-bgColor-red', if([$Status]!='' && Number([$DueDate])==0 && [$Owner.title]!='','ms-bgColor-orangeLighter',if([$Status]!='' && Number([$DueDate])!=0 && [$Owner.title]!='','ms-bgColor-gray100','')))"
    }

     

    Output

    Where StatusOwner and DueDate are internal names of your SharePoint list columns. You can get the internal name of your SharePoint list columns by following this article: How to find the Internal name of columns in SharePoint Online? 

     

    Here, I have used Number([$DueDate]) == 0 to check if Date & Time column in SharePoint list is empty or not. You can find other ways to check if date & time column is empty or not using SharePoint JSON formatting at: SharePoint JSON formatting: Check if date & time column is blank/empty 


    Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

      • ganeshsanap's avatar
        ganeshsanap
        MVP

        Chonski950 

         

        You are welcome. Can you please confirm if the provided solution worked for you?


        Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

  • Chonski55 

     

    What is the column type for each of these fields? 

     

    I am assuming:

    1. Status: Choice - Is this is single selection or multiple selection column?
    2. Owner: Person or Group - Confirm the column type & if it is a single selection or multiple selection column?
    3. Date: Date & Time

    I am asking this because JSON formatting will be based on column types in SharePoint.


    Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

Resources