How to use conditional if formatting on a column to set a value

Occasional Contributor

For example in the column formatting tab

DPerez1280_0-1658250161485.png

Is it possible to have a case statement that updates the value of one column based off the value of another like so? That is, without using power automatE?

2 Replies

@childishbambino You can add conditional formula by going to +New -> Hit the drop down in top right corner -> Edit columns -> Hover over a column -> ellipses -> Edit conditional formula.

Conditionalformula.png

@childishbambino First of all, SharePoint column formatting is used to customize how fields in SharePoint lists/libraries are displayed and it does not actually set value of columns.

 

So, if you have to set/store the actual value in column, you cannot use the JSON formatting. You have to use another approaches like using calculated column, power automate or power apps customized forms (based on your requirements).

 

However, if you just want to show the value in list view, you can use the JSON formatting like below example:

JSON code used:  

 

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "div",
    "txtContent": "=if([$Title] == 'Result A', 'Result A is true', if([$Title] == 'Result B', 'Result B is true', if([$Title] == 'Result C', 'Result C is true', '')))"
}

 

Output

ganeshsanap_0-1658316205484.png


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.