Help

IF statements with numbers and time

Topic Labels: Base design
Solved
Jump to Solution
289 3
cancel
Showing results for 
Search instead for 
Did you mean: 
VedranN
4 - Data Explorer
4 - Data Explorer

Hi everybody,

if I can ask for help with formulas in IF statements

I have developed Glide app with Airtable, works really good.

I have a table WorkOrders, and among other columns, I have:

"Start time", "Start kilometers", "End Time", "End kilometers", "Total km", "Total time", "Status".

This formula is in column "Status", works good:

IF(OR({NameSurname}="",{Startkm}=""),"CREATED",IF({Endkm}="","IN PROCESS",IF({Endkm}>{Startkm},"COMPLETED")))

How can I add another Status, Canceled?

Button CANCEL in Glide updates the fields: Startkm and Endkm to 0 (zero), StartTime and EndTime to CurrentTime (same data in StartTime and EndTime)

Can you help me with the formula?

Thank you very much  

 

 

1 Solution

Accepted Solutions
TheTimeSavingCo
18 - Pluto
18 - Pluto

Hm, personally I'd split it out like this as it's easier for me to look at:

IF(
  AND(
    Startkm="",
    Endkm="",
    Startkm != "0",
    Endkm != "0"
  ),
  "CREATED"
) &
IF(
  AND(
    NameSurname,
    Startkm,
    Endkm=""
  ),
  "IN PROCESS"
) &
IF(
  AND(
    Endkm > Startkm,
    NameSurname
  ),
  "COMPLETED"
) &
IF(
  AND(
    NameSurname,
    Startkm = "0",
    Endkm = "0"
  ),
  "CANCELED"
)

Screenshot 2024-04-17 at 5.29.14 PM.png

See Solution in Thread

3 Replies 3
TheTimeSavingCo
18 - Pluto
18 - Pluto

Hm, personally I'd split it out like this as it's easier for me to look at:

IF(
  AND(
    Startkm="",
    Endkm="",
    Startkm != "0",
    Endkm != "0"
  ),
  "CREATED"
) &
IF(
  AND(
    NameSurname,
    Startkm,
    Endkm=""
  ),
  "IN PROCESS"
) &
IF(
  AND(
    Endkm > Startkm,
    NameSurname
  ),
  "COMPLETED"
) &
IF(
  AND(
    NameSurname,
    Startkm = "0",
    Endkm = "0"
  ),
  "CANCELED"
)

Screenshot 2024-04-17 at 5.29.14 PM.png

Thank you very very much, it works 🙂

 

Funny example of 'when you code is a mess, but it works  🤣',
I would not recommend it to use in real life

Alexey_Gusev_0-1713351065152.png