0

Using JSON formatting, is it possible to hide a column based on another column value.

Example:
View displays columns A, B, C and D
View is limited to one row
If the value in column D equals Yes, don't display column A.

Edit - SP Online modern site is being used.

0

If your are not using a modern site, i will advise you to use JSLink

CSharpCorner

1
  • I'll give it a shot and report back. Thx! – Taco_Buffet Dec 3 '19 at 15:30
0

You could use the below JSON code to format the column A:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "debugMode": true,
  "elmType": "div",
  "txtContent": "@currentField",
  "style": {
    "display": "=if([$ColumnD]=='Yes','none','')"
  }
}

Test Result:

enter image description here

2
  • close. I'm wanting to hide the column, not just the value. my view is filtered to one row. – Taco_Buffet Dec 6 '19 at 22:15
  • So you want to hide the column header too. However, we cannot not only hide only one column header using JSON View Formatting. We could use "hideColumnHeader": true to hide column headers, but it would hide all column headers. Please read here for more :docs.microsoft.com/en-us/sharepoint/dev/… – Michael Han_MSFT Dec 9 '19 at 8:49

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.