Forum Discussion
Column formatting with a condition
I have a custom list in SharePoint online for a project dashboard that I'm creating. I have some conditional formatting that changes the background colours based on Status (red for not started, orange for in progress, and green for completed). I would also like the Project title to be in bold and sub tasks not to be in bold. I have another field called Task Rank.
What I would like to do is have the following:
if task rank = 1, make the task name show up as bold, otherwise don't do anything,
then
if the status is completed make the background green, not started it is red, and in progress orange.
Here is the json for bold:
{
"$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
"elmType": "div",
"style": {
"font-weight": "bold"
},
"txtContent": "@currentField"
}
Here is the json for the background colour:
{
"$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
"debugMode": true,
"elmType": "div",
"txtContent": "@currentField",
"style": {
"background-color": {
"operator": "?",
"operands": [
{
"operator": "<",
"operands": [
"[$_x0025__x0020_Complete]",
"0.5"
]
},
"red",
{
"operator": "?",
"operands": [
{
"operator": "<",
"operands": [
"[$_x0025__x0020_Complete]",
"1"
]
},
"orange",
"green"
]
}
]
},
"color": "white",
"padding-left": "10px"
}
}
Finally, a screen shot of the current list: