0

How do I extend the solution provided here to highlight a row if, say, column "LookUpColumnABC" is empty?

I tried incorporating if([$LookUpColumnABC] == '', if([$LookUpColumnABC] == "" and similar code into this solution but that's not working.

How do I check for the absence of a value and highlight the entire row?

2 Answers 2

1

Comparing to an empty string as you are showing is fine in most cases. But you can also use the length operator which seems to cover all cases equally well. I'm not sure everything you're trying to accomplish, but here's a very basic view format using this logic to make rows with empty values in the Lookup column red and others blue:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
  "additionalRowClass": "=if(length([$Lookup])==0,'ms-bgColor-red','ms-bgColor-blue')"
}

length is used to determine the number of items in an array (not string length) and for anything other than arrays always returns 1 when a value is present and 0 when not.

1
  • Thank you, using the length function works, but I did have to append lookupValue to this particular column like so: if(length([$Lookup.lookupValue])==0 Dec 10, 2021 at 23:31
0

You can use JSON like:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
  "additionalRowClass": "=if([$LookUpColumn.lookupValue], if([$LookUpColumn.lookupValue] > 75, 'sp-field-severity--good', if([$LookUpColumn.lookupValue] < 75 && [$LookUpColumn.lookupValue] > 50, 'sp-field-severity--low', if([$LookUpColumn.lookupValue] < 50 && [$LookUpColumn.lookupValue] > 25,'sp-field-severity--warning', if([$LookUpColumn.lookupValue] < 25,'sp-field-severity--blocked', '')))), '')"
}

Example:

enter image description here

Here I am using the simple expression like:

if([$LookUpColumnABC.lookupValue], "Value available", "Value not available")

I am referring the "Simplest way" provided in this article: SharePoint JSON formatting: Check if column is blank/empty

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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