# IF statements with numbers and time

Topic Labels: Base design
Solved
290 3
cancel
Showing results for
Did you mean:
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
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"
)

3 Replies 3
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"
)

4 - Data Explorer

Thank you very very much, it works 🙂

12 - Earth

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