Untitled
unknown
plain_text
a year ago
1.3 kB
1
Indexable
let // Function to safely handle a date or return null if there's an error or invalid data ValidateDate = (dateValue) => let result = try if dateValue is date then dateValue else null otherwise null in result, // Function to determine the sailing status based on ATD, ETD, and Carrier_ETD DetermineSailingStatus = (atd as nullable date, etd as nullable date, carrier_etd as nullable date) as text => if ValidateDate(atd) <> null then "Sailed" else let validETD = ValidateDate(etd), validCarrierETD = ValidateDate(carrier_etd), duration = if validETD <> null and validCarrierETD <> null then Duration.Days(validCarrierETD - validETD) else null, result = if duration = null then "No data" else if duration > 0 then "Delayed by " & Number.ToText(duration) & " days" else if duration < 0 then "Sailing earlier by " & Number.ToText(-duration) & " days" else "On Schedule" in result in DetermineSailingStatus([ATD], [ETD], [Carrier_ETD])
Editor is loading...
Leave a Comment