Jun 05 2020 10:39 AM
I am trying to create relatively simple conditional column formatting in a SharePoint Online list.
This works (the conditions 1==1 and 2==2 are placeholders to simplify the examples here):
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "txtContent": "@currentField", "style": { "color": "=if(1==1, '#ff0000', '#ff00ff')" } }
But when I introduce an AND function, it doesn't work (no formatting occurs):
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "txtContent": "@currentField", "style": { "color": "=if(AND(1==1, 2==2), '#ff0000', '#ff00ff')" } }
What am I doing wrong?
Jun 05 2020 12:25 PM
Solution@E_Mahn you need to be using && between the 2 criteria of the if statement, for example:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"color": "=if([$FlowHasRun]=='No' && [$Status2]=='Completed' , '#468259', '#c00000')"
}
}
Rob
Los Gallardos
Microsoft Power Automate Community Super User
Jun 05 2020 12:25 PM
Solution@E_Mahn you need to be using && between the 2 criteria of the if statement, for example:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"color": "=if([$FlowHasRun]=='No' && [$Status2]=='Completed' , '#468259', '#c00000')"
}
}
Rob
Los Gallardos
Microsoft Power Automate Community Super User