# And/Or for If → Than → Else Column

**URL:** <https://community.glideapps.com/t/and-or-for-if-than-else-column/64920>\
**Category:** Feature Requests\
**Created:** [August 11, 2023, 10:51am UTC](https://community.glideapps.com/t/and-or-for-if-than-else-column/64920 "2023-08-11T10:51:41Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Airon\_Studio](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/airon_studio/32/55919_2.png) [@Airon\_Studio](https://community.glideapps.com/u/Airon_Studio)\
**Post date:** [August 11, 2023, 10:51am UTC](https://community.glideapps.com/t/and-or-for-if-than-else-column/64920/1 "2023-08-11T10:51:41Z")

</div>

Please add option in conditions in ‘If → Then → Else’ column to add an ‘and/or’ like in the visibility conditions.

Thanks 🙏

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [August 11, 2023, 10:54am UTC](https://community.glideapps.com/t/and-or-for-if-than-else-column/64920/2 "2023-08-11T10:54:01Z")

</div>

Can you give a practical example of something you’re trying to do, but can’t?

Chances are it is possible, with a little bit of creative thinking.

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [August 11, 2023, 12:02pm UTC](https://community.glideapps.com/t/and-or-for-if-than-else-column/64920/3 "2023-08-11T12:02:30Z")

</div>

Please keeps the votes going on this one.

> [@Better and more consistent IF THEN logic](https://community.glideapps.com/t/better-and-more-consistent-if-then-logic/24317):
>
> I’ve spent the past few days trying to work out some IF/THEN logic for a side project. The problem is that this is something I could have worked out in a matter of a few minutes with actual code. I’m running into several limitations with the current IF/THEN logic we currently have in Glide. First of all there inconsistencies between what’s possible with an IF/THEN column, and what’s possible with If/Then logic in visibility conditions or actions. Most importantly, an IF/THEN column only all…

---

<div class="post-metadata">

**Author:** ![Airon\_Studio](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/airon_studio/32/55919_2.png) [@Airon\_Studio](https://community.glideapps.com/u/Airon_Studio)\
**Post date:** [August 11, 2023, 12:40pm UTC](https://community.glideapps.com/t/and-or-for-if-than-else-column/64920/4 "2023-08-11T12:40:02Z")

</div>

Hey @Darren_Murphy, I’m working on a car rental app (you helped me a last week with it [here](https://community.glideapps.com/t/car-rental-app-search-for-available-cars-within-given-date-time-range/64631)).

When a user searches for available vehicles within a timeframe, I want to display the price it will cost them for each vehicle (prices are different for each vehicle class/type). When they select the vehicle and reserve, I want to create a record in the bookings table and set the price for that booking with ‘set column values’ from the price it was displaying for them while searching.

Each vehicle has an hourly rate and a daily rate. For example, a car can have an hourly rate of $20/hr and a daily rate of $90/day. I want to set one total booking price column with the following conditions:

If total booking days is equal to or greater than 1, then apply daily rate.

If total booking days is less than 1, **AND total price (hourly rate) is greater then daily rate**, then apply daily rate. Else, apply holy rate.

Essentially, if someone is booking for example for 5 hours, I don’t want to apply hourly rate (which will total $100, and exceeds daily rate), instead I want to apply the daily rate.

The only way I see it being done now is by setting visibility conditions on the component displaying the price on each vehicle while user is searching, and setting the same conditions again when setting column values in the action flow when finalizing booking.

It would be much easier if I hade one If Than Else column that I would be able to set above conditions, and use it for displaying the price while searching, and setting column values in final booking.

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [August 11, 2023, 12:56pm UTC](https://community.glideapps.com/t/and-or-for-if-than-else-column/64920/5 "2023-08-11T12:56:15Z")

</div>

Okay, try this:

- Start by creating two math columns. One to calculate the total cost based on the daily rate, and another to calculate the total based on the hourly rate.
- And then create your if-then-else column as follows:  
– If number of days is equal to or greater than 1, then calculated daily total  
– If calculated hourly total is greater than calculated daily total, then calculated daily total  
– Else calculated hourly total

I think that should do it?

---

<div class="post-metadata">

**Author:** ![Airon\_Studio](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/airon_studio/32/55919_2.png) [@Airon\_Studio](https://community.glideapps.com/u/Airon_Studio)\
**Post date:** [August 11, 2023, 1:20pm UTC](https://community.glideapps.com/t/and-or-for-if-than-else-column/64920/6 "2023-08-11T13:20:11Z")

</div>

I’ll give a precise example to demonstrate the problem and why the solution you provided won’t work.

Car costs $20/hr and $70/day. User wants to reserve it for 5 hours. As it stands, the math column calculating the hourly rate ($20 \* 5) will total $100, and the math column calculating the daily rate (booking\_days \* $70) will total $14.58 (since total booking days for 5 hours = 0.21).

In this case, I can’t apply the calculated daily rate since it’s not accurate ($14.58), rather, I need to apply the daily rate X1 ($70).

That’s why I need the ‘AND’ in my condition to check if hourly rate is greater than daily rate, AND booking is less than 1 day, apply daily rate X1.

Without the AND, it will always apply the daily rate X1 to any booking that’s 1+ days since the hourly rate will surely be greater then the daily rate (the daily rate is a discount).

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [August 11, 2023, 1:36pm UTC](https://community.glideapps.com/t/and-or-for-if-than-else-column/64920/7 "2023-08-11T13:36:29Z")

</div>

> [@Airon\_Studio](#):
>
> Car costs $20/hr and $70/day. User wants to reserve it for 5 hours. As it stands, the math column calculating the hourly rate ($20 \* 5) will total $100, and the math column calculating the daily rate (booking\_days \* $70) will total $14.58 (since total booking days for 5 hours = 0.21).

ah, that makes it clearer.  
Okay, still quite doable. Just need to adjust the logic slightly:

– If booking days is equal to or greater than 1, then calculated daily total  
– If calculated total based on hourly rate is greater than daily rate, then daily rate  
– Else calculated total based on hourly rate

The difference is in the second case. Instead of comparing the calculated hourly total to the calculated daily total, we compare it to the daily _rate_.

One thing I should point out about the if-then-else column is that it exits as soon as a condition passes, and ignores any remaining conditions. So if we apply the above to your example:

- Case 1: Booking period is less than one day: fails - move to next case
- Case 2: Calculated total based on hourly rate ($100) is greater than daily rate ($70): passes - return daily rate
- Case 3: Ignored.

@Airon_Studio - and just to demonstrate that it works, please watch this:

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [August 11, 2023, 1:49pm UTC](https://community.glideapps.com/t/and-or-for-if-than-else-column/64920/8 "2023-08-11T13:49:14Z")

</div>

> [@Airon\_Studio](#):
>
> Else, apply holy rate.

Does the holy rate apply when you book the popemobile through the app? 😁

---

<div class="post-metadata">

**Author:** ![Airon\_Studio](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/airon_studio/32/55919_2.png) [@Airon\_Studio](https://community.glideapps.com/u/Airon_Studio)\
**Post date:** [August 11, 2023, 2:15pm UTC](https://community.glideapps.com/t/and-or-for-if-than-else-column/64920/9 "2023-08-11T14:15:24Z")

</div>

Thank you very much for the reply and the video! I tried it and it works. @Darren_Murphy you are fantastic!

I wasn’t sure if it would work this way since it isn’t clear how the conditions work if they aren’t met.

Now Iv’e tried it and it works, thank you for that.

P.s. what’s the formula to calculate how many hours between two times, I was only able to figure out how to calculate the days. HOUR(date/time - date/time) only gives me the hour number but not total calculated hours.

---

<div class="post-metadata">

**Author:** ![Airon\_Studio](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/airon_studio/32/55919_2.png) [@Airon\_Studio](https://community.glideapps.com/u/Airon_Studio)\
**Post date:** [August 11, 2023, 2:16pm UTC](https://community.glideapps.com/t/and-or-for-if-than-else-column/64920/10 "2023-08-11T14:16:16Z")

</div>

🙃

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [August 11, 2023, 2:18pm UTC](https://community.glideapps.com/t/and-or-for-if-than-else-column/64920/11 "2023-08-11T14:18:04Z")

</div>

> [@Airon\_Studio](#):
>
> P.s. what’s the formula to calculate how many hours between two times, I was only able to figure out how to calculate the days. HOUR(date/time - date/time) only gives me the hour number but not total calculated hours.

Here is what I used:

```auto
Round(End - Start,2)*24

```

 ![CleanShot 2023-08-11 at 22.16.09@2x](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/a/1/a11307e89462d1fe1ef4cf00be342c5b53cf2046.png)

> [@Airon\_Studio](#):
>
> I wasn’t sure if it would work this way since it isn’t clear how the conditions work if they aren’t met.

Yeah, it takes a little to get used to how the if-then-else column works (and how it can be used) - it’s not particularly intuitive.

---

<div class="post-metadata">

**Author:** ![Airon\_Studio](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/airon_studio/32/55919_2.png) [@Airon\_Studio](https://community.glideapps.com/u/Airon_Studio)\
**Post date:** [August 11, 2023, 2:19pm UTC](https://community.glideapps.com/t/and-or-for-if-than-else-column/64920/12 "2023-08-11T14:19:01Z")

</div>

Thank you 🙏

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)\
**Post date:** [August 18, 2023, 2:19pm UTC](https://community.glideapps.com/t/and-or-for-if-than-else-column/64920/13 "2023-08-18T14:19:38Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
