Search code examples
javascriptif-statementconditional-statementssharepoint-onlinecalculated-columns

Hide a field in SharePoint based on Conditions from another field


I have a SharePoint list that I'm using to track employee sick time. The "Actual Arrival/Departure Time" field is meant to display the actual time that the employee arrived/departed if they weren't out for the entire day.

What I'm trying to do is hide this field and set it to 'N/A' if the "Leave Type" field is set to 'Early Departure (unscheduled)' or 'Tardy (unscheduled)'

The formula I have in here currently is:

=IF([Leave Type]=OR("Early Departure (unscheduled)","Tardy (unscheduled)"),TEXT([Arrival/Departure Time],"hh:mm AM/PM"), "N/A")

and it is a "single line of text" field.

However, the results I get when I use the early departure or tardy option is a #NAME? error and when I use anything else I get a #VALUE! error.

Does anyone know how I can accomplish what I'm trying to do?


Solution

  • We can use the formula below to achieve it.

    =IF(OR([Leave Type]="Early Departure (unscheduled)",[Leave Type]="Tardy (unscheduled)"),"N/A",TEXT([Arrival/Departure Time],"hh:mm AM/PM"))
    

    enter image description here