# If-this-and-that-then

**URL:** <https://community.glideapps.com/t/if-this-and-that-then/2635>\
**Category:** Ask for Help\
**Created:** [December 5, 2019, 1:51am UTC](https://community.glideapps.com/t/if-this-and-that-then/2635 "2019-12-05T01:51:16Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rogelio](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/rogelio/32/1054_2.png) [@Rogelio](https://community.glideapps.com/u/Rogelio)\
**Post date:** [December 5, 2019, 1:51am UTC](https://community.glideapps.com/t/if-this-and-that-then/2635/1 "2019-12-05T01:51:16Z")

</div>

I’m trying use the IF-THEN-ELSE feature to work out a result, this is my case:

I have a column labelled ‘`Is Class`’ with values either `TRUE` or `FALSE`  
I have another column labelled ‘`Remaining Classes`’ with a positive numeric value, eg, `1`, `2`, `3`, `4`, etc…

I want to use the IF-THEN-ELSE to work out the following

IF ‘`Is Class`’ = `TRUE`  
AND  
IF ‘`Remaining Classes`’ \> `0`  
THEN  
= `TRUE`  
ELSE  
=`FALSE`

I need both cases to meet the criteria in order to produce a TRUE result.

Is this possible?

---

<div class="post-metadata">

**Author:** ![George\_B](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/george_b/32/534_2.png) [@George\_B](https://community.glideapps.com/u/George_B)\
**Post date:** [December 5, 2019, 3:23am UTC](https://community.glideapps.com/t/if-this-and-that-then/2635/2 "2019-12-05T03:23:38Z")

</div>

I didn’t do extensive testing but this should work I think. You need to do it in two steps. Also the sort of magic with the math is that for True False values True = 1 and False = 0, that is why the math works.

[https://i.gyazo.com/f7a64815ae078c12b60469391241af7c.mp4](https://i.gyazo.com/f7a64815ae078c12b60469391241af7c.mp4)

---

<div class="post-metadata">

**Author:** ![Rogelio](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/rogelio/32/1054_2.png) [@Rogelio](https://community.glideapps.com/u/Rogelio)\
**Post date:** [December 5, 2019, 4:17am UTC](https://community.glideapps.com/t/if-this-and-that-then/2635/3 "2019-12-05T04:17:15Z")

</div>

Thanks George - your suggested approach helped, although since Class value is being calculate based on the value another column into a TRUE or FALSE (but of course these could be 1 or 0 as well haha), the ‘MathIt’ column didn’t work, so I had to convert Class values of TRUE or False into either 1 or 0, which when multiplied either gave me 0 or a \>0 result 🙂

---

<div class="post-metadata">

**Author:** ![George\_B](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/george_b/32/534_2.png) [@George\_B](https://community.glideapps.com/u/George_B)\
**Post date:** [December 5, 2019, 4:20am UTC](https://community.glideapps.com/t/if-this-and-that-then/2635/4 "2019-12-05T04:20:47Z")

</div>

Well in my defense you didn’t say it was being calculated. In my test spreadsheet I created that row as hard coded true or false values, and it worked fine as you saw in the video. But as long as it gave you the idea, all is good.

---

<div class="post-metadata">

**Author:** ![ionamol](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ionamol/32/1951_2.png) [@ionamol](https://community.glideapps.com/u/ionamol)\
**Post date:** [December 5, 2019, 5:45am UTC](https://community.glideapps.com/t/if-this-and-that-then/2635/5 "2019-12-05T05:45:24Z")

</div>

Hi @Rogelio, I think that it’s easier using Google Sheets. Take a look at my screenshot, isn’t it what you want?  
PS: You don’t need the last ( **, " "** )

 ![05](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/2X/7/7e76ac5515675cc1bcdb074e8efe317234149a8a.png)

---

<div class="post-metadata">

**Author:** ![Rogelio](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/rogelio/32/1054_2.png) [@Rogelio](https://community.glideapps.com/u/Rogelio)\
**Post date:** [December 5, 2019, 5:56am UTC](https://community.glideapps.com/t/if-this-and-that-then/2635/6 "2019-12-05T05:56:44Z")

</div>

Yep! that works too 🙂

---

<div class="post-metadata">

**Author:** ![Mark](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mark/32/125_2.png) [@Mark](https://community.glideapps.com/u/Mark)\
**Post date:** [December 5, 2019, 6:20am UTC](https://community.glideapps.com/t/if-this-and-that-then/2635/7 "2019-12-05T06:20:32Z")

</div>

Unfortunately If/Then/Else doesn’t do AND yet, but you can invert the condition, which gives you

- IF `Is Class` is not `TRUE` THEN `FALSE`
- ELSE IF `Remaining Classes` \<= 0 THEN `FALSE`
- ELSE `TRUE`

---

<div class="post-metadata">

**Author:** ![George\_B](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/george_b/32/534_2.png) [@George\_B](https://community.glideapps.com/u/George_B)\
**Post date:** [December 5, 2019, 1:29pm UTC](https://community.glideapps.com/t/if-this-and-that-then/2635/8 "2019-12-05T13:29:27Z")

</div>

@ionamol It may have a delay if you do it in sheets. The reason to do it in Glide would be one of speed. Yes sheets is more straight forward but not instantaneous.

---

<div class="post-metadata">

**Author:** ![ionamol](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ionamol/32/1951_2.png) [@ionamol](https://community.glideapps.com/u/ionamol)\
**Post date:** [December 5, 2019, 2:51pm UTC](https://community.glideapps.com/t/if-this-and-that-then/2635/9 "2019-12-05T14:51:34Z")

</div>

Thanks @George_B, I was wondering if doing that inside Glide would be faster.

---

<div class="post-metadata">

**Author:** ![Rogelio](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/rogelio/32/1054_2.png) [@Rogelio](https://community.glideapps.com/u/Rogelio)\
**Post date:** [December 12, 2019, 3:38am UTC](https://community.glideapps.com/t/if-this-and-that-then/2635/10 "2019-12-12T03:38:27Z")

</div>

How can I use a similar approach to work our IF-THIS-OR THAT-THEN-THIS?

---

<div class="post-metadata">

**Author:** ![Mark](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mark/32/125_2.png) [@Mark](https://community.glideapps.com/u/Mark)\
**Post date:** [December 12, 2019, 5:11am UTC](https://community.glideapps.com/t/if-this-and-that-then/2635/11 "2019-12-12T05:11:50Z")

</div>

Here’s a concrete example: Let’s say we have a column “RHR”, which gives a person’s resting heart rate, and we want to make a new column that says either “Normal” or “Abnormal” under these condition:

- if RHR is between 40 and 80 inclusive, it should be “Normal”
- otherwise it should be “Abnormal”

There are two ways of formulating this:

### with AND:

- if RHR \>= 40 **and** RHR \<= 80 then “Normal”
- else “Abnormal”

### with OR:

- if RHR \< 40 **or** RHR \> 80 then “Abnormal”
- else “Normal”

The OR one is very easy to state differently by just breaking up the OR into two cases:

- if RHR \< 40 then “Abnormal”
- if RHR \> 80 then “Abnormal”
- else “Normal”

That’s it.

Any combined condition that you can write with a bunch of ANDs [you can rewrite with a bunch of ORs, and vice versa](https://en.wikipedia.org/wiki/De_Morgan%27s_laws), if you also turn around the individual conditions.
