Forum Discussion
spinman
Oct 26, 2019Tin Contributor
JSON Formula Help
I am new to using JSON but I'm looking to do the following any help would be appreciated. I have a Sharepoint list that has a Date Column labeled Expiration Date and I'd like to show green if a date...
spinman
Oct 29, 2019Tin Contributor
Thanks for your help with this. This works for this one.
What about this.. I have a column called Effective Date and a column called Exp Date. How would I go about coloring the Effective date green if its within 30 days of the Exp Date and red if its after 30 days of the exp date?
Matti Paukkonen
Nov 03, 2019Iron Contributor
Hi spinman,
Here is an example.
{
"$schema": "<a href="<a href="https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json" target="_blank">https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json</a>" target="_blank"><a href="https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json</a" target="_blank">https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json</a</a>>",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"background-color":
{
"operator": "?",
"operands": [
"=length([$EffectiveDate]) > 0",
{"operator":"?",
"operands":[
{"operator":"<",
"operands": [
"[$EffectiveDate]","[$ExpDate]"
]},"",
{"operator":"?",
"operands":[
{"operator":"<","operands":[
"[$EffectiveDate]",
{
"operator": "+",
"operands": [
"[$ExpDate]",
2592000000
]
}]},"green","red"
]},""
]}
,""
]
}
}
}
Notice that actual value for comparing one month is: 2592000000, it was wrong on my first example.