If_then_else

Hi there,

I’m building an app to manage a fleet of cars and I want to create an if_then_else condition that shows says if the trip is a round trip then display as round trip else show one way. The use case is that a driver can select a oneway trip or a round trip and if they choose a round trip then it needs to double the kms. However when I choose the if_then_else functionality the output doesn’t seem to calculate the value from the correct column and the value shows multiple digits instead of a whole number despite the fact that I set the precision to one in the column it’s receiving the data from.
Please can you help identify what I’m doing wrong?


Could you share a screenshot with the Trip Type coloumn as well?

The problem is that you are trying to match the Trip Type column with the calculated round trip distance, and I assume they will never match, so your if-then-else column as it is will always return the one way distance.

You need to match the actual values in your Trip Type column in the first case of the if-then-else. So something like:

  • If Trip Type is Round Trip (literal text), then “Calculated Round Trip Distance” (your math column)
  • Else One Way Distance

The first row doesn’t have a value because the if_the_else is was not configured

OK if I understand correctly I’m not supposed to choose a column but rather type the words Round Trip and the choose the math column. I’ll try this. Thank you.

Thanks so much it worked, but it didn’t fix the decimal issue even though I’ve set the precision to 1, how can I fix that?


Idk if this would fully work, but maybe calculate the Distance without the KM units and then add them via a separate template column then try and use it in the math column. I just think the unit may be confusing it. (so have “One Way Distance” (distance coloumn) and then “One Way Distance + unit” (templete coloumn) and use the first distance coloum in the math equation)

You need to modify your math formula, use the following:
Round(OneWayDistance * 2,1)

Thanks, the formula works for round trip but not single, unfortunately. Is there something else I need to add to it?

It doesn’t allow me to add a distance column without adding a unit. It’s either miles or kms. Hope I understood it correctly.

Create another math column with the same formula and point it at the One Way Distance column.

Alternatively, you could use a single math column that rounds the result of your if-then-else column. That would be one less column required.

1 Like

Hi there,

Thank you for your assistance so far. The AI assistant also proposed replacing the if-then-else column with a math column instead and gave me a configuration to enter but Glide does not accept the syntax. OneWayDistance * 2 when Trip Type is Round Trip, otherwise OneWayDistance. I’m not a developer so I’m unsure what to enter, would it be possible for you to assist me please? These are what I’ve tried.


No, the math column doesn’t support conditional logic like that, so you need to keep the if-then-else column. My suggestion was to add another math column, and use that to round the result of the if-then-else column. So keep all the columns like below:

Then add one more math column using the same formula that I gave you earlier, but use the output of the if-then-else column in the formula.

1 Like

Thank you, this worked. Appreciate all your help :folded_hands:

1 Like