1

I am trying to make the text say Expired or Current compared to a date column OR stay blank if the date column is blank. So far, I have:

"txtContent": "=if([$ExpiryDate]) == '',  '' , if([$ExpiryDate] <= @now, 'Expired', if([$ExpiryDate] > @now, 'Current', '')))"

But for whatever reason, the column then shows the ENTIRE formula in the column instead. I have tried several different permutations of the above, including isblank, but I just can't seem to get the syntax exactly how SharePoint likes it.

1
  • I took that offending second bracket out, but now it just makes everything not Current to Expired, even if date column is blank. Commented Jul 10, 2020 at 4:27

1 Answer 1

2

You can use Number(DateTimeColumn) == 0 to check if the date column is blank or not. This is the major hint, rest you can build the JSON code around it according to your other conditions.

So, try something like this:

=if(Number([$ExpiryDate]) == 0, '' , if([$ExpiryDate] <= @now, 'Expired', 'Current'))

You can find other ways to check if date & time column is empty or not at: SharePoint JSON formatting: Check if date & time column is blank/empty

Reference:

Make a column no background colour if no value

1
  • 1
    Excellent, thank you! I didn't know you could check date columns using Number, that's so helpful. Commented Jul 10, 2020 at 7:40

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.