Conditional JSON Formating a choice column based on the value of another column

Viewed 18

I want to select a choice on a column if a specific value is on another column.

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "@currentField",
  "attributes": {
    "class": "=if(indexOf(toLowerCase([$Location],'Hawaii') != -1,'Deliver',''))"
  }
}
1 Answers

Use below JSON in column formatting option for your column:

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "div",
    "txtContent": "@currentField",
    "attributes": {
        "class": "=if(indexOf(toLowerCase([$Location]), toLowerCase('Hawaii')) != -1, 'Deliver', @currentField)"
    }
}

Note: JSON formatting does not set the actual column value, it only customizes the display of column to show the value in list view.

Related