If-this-and-that-then

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?

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.

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 :slight_smile:

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.

1 Like

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 ( , " " )

Yep! that works too :slight_smile:

1 Like

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
2 Likes

@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.

2 Likes

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

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

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, if you also turn around the individual conditions.

2 Likes