Question

I've been struggling with this for a few days now and wondered if anyone could help!

I have a SharePoint list (attendance tracking) with 4 date columns:

  • Arrival Time (this is filled-in using [Today] by default when the item is created)
  • Sign-out
  • Sign-in
  • Exit Time

And a text column called Status.

I want the Status column to quickly show whether the person is in the building, or out, based on the 4 date columns (e.g. if there is a time/date in the Arrival Time column, but not in Sign-out column then they are in the building.

I am trying to adapt some json on GitHub but I am really struggling to get the if statements down!

This is ideally what I want to achieve: enter image description here

Any help would be greatly appreciated!

Was it helpful?

Solution

Try the following:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "=if(Number([$SignOutTime])!=0 && Number([$ExitTime])!=0, 'Out', if(Number([$SignOutTime])!=0 && Number([$SignInTime])==0,'Out',if(Number([$ArrivalTime])==0, 'Out', 'In')))",
  "attributes": {
    "class": "=if(Number([$SignOutTime])!=0 && Number([$ExitTime])!=0,'sp-field-severity--severeWarning',if(Number([$SignOutTime])!=0 && Number([$SignInTime])==0,'sp-field-severity--severeWarning',if(Number([$ArrivalTime])==0, 'sp-field-severity--severeWarning', 'sp-field-severity--good')))"
  }
}

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top