Forum Discussion
AdmiralS
May 11, 2020Copper Contributor
JSON for Formatting Dates
I currently have a SharePoint list that we use for tracking Insurance Policy Expiration dates. I would like it to format with the warning format for dates that are within the next 30 days. I have r...
AdmiralS
May 11, 2020Copper Contributor
Thanks!
I need to color for 3 scenarios against the same column though -
Red - Dates Before Today
Yellow- Dates between Today and 30 days out
Green - Dates 30 days and forward from Today
Can I do that all in the same JSON conditional filter?
Vikram_Samal
May 11, 2020MCT
AdmiralS Yes just you have to use multiple Ifs I have shown an example which can follow and modify as per your need.
This is the code:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"color": "=if([$Color] == 'Red', 'red', if([$Color] == 'Green', 'green',if([$Color] == 'Blue', 'Blue', if([$Color] == 'Yellow', 'Yellow', 'Orange'))))"
}
}Hope this helps mark the response appropriately if it helps to solve your problem.