# If Then Else with two or more criteria!

A quick question gliders,
Why If Then Else doesn’t work when you specify two math values?
Example 1: I specified if Timer is less than 0, show extra time. (Only one criteria)

Example 2: If extra is less than 0, then extra time. If equals or greater than 0, show timer. in this example, all numbers got messed up! any solution for this?

Seems like you were pointing to a math column with units specified for that column only. You should do the if then else with a template column.

2 Likes

I see! I thought looking it up messes columns to I went to the original sheet and worked it out with no positive results. Now I can see if more than one criteria to be used in an If Then Else column, template must be used.

Thank you is not enough for you brother. God bless you, you helped me a big time.

1 Like

God bless you as well with your great work, my pleasure to help again.

2 Likes

Actually I am trying to create teaching apps for IELTS as well as English students to help them make a difference. I really appreciate your patience. One day, when more and more students succeed, I will make sure they join this community and thank you in person.

2 Likes

Is possible to show example of using template column for If-then-else?
thanks

It’s just a way of adding the units to the end of the number. The actual number column allows you to add units but they are kept specifically for that column and won’t transfer when you use an ITE on the number column, only the number part is transferred to the ITE result.

Hence I advised Mr. @DareSteps to have a template column to lock the units in.

2 Likes

I would love to explain it to you as @ThinhDinh solved it.

I had an issue before. I wanted to use If Then Else for two MATH values, if it is less than zero, THEN Extra Timer. If it is equal or greater than zero, THEN Timer.

When it comes to IF THEN ELSE, if you want to use only one math value, it works perfect. Just like in Example 1. as you see the second value, if Timer equals or greater than 0, then (Left it empty) therefore If then else worked perfect.

Example 2: In this example, I didn’t leave the second value empty. In fact I wanted to run If Then Else for both two columns. Here is the issue, If Then Else didn’t work in this case. You must convert both math values to two TEMPLATES.

Example 3: I converted them to Template column now and they work perfectly.

If you mean I created Templates? here is an example: I already have Timer and Extra Time Templates. like this one:

4 Likes

thanks @DareSteps

Are you building timers in glide with loops using just the glide columns?

no timer at moment…i am using timer for visibility control of buttons…i think that was resolved with help from our wonderful “Gurus” here…in If-then-else, i still have not got the hang of it yet, so a bit more knowledge will help to build better Apps.

Very nice, no one here has been brave enough to tackle timers directly in glide sheets just yet. We started a theoretical but I was hoping someone else wanted to give it a go.

What do you need timers for? I might be able to help you. Give me an example. I’ve created timers for Check in and out without specified times, I also set start and end time with timers. It all depends on what you are looking for.

It’s not something we can do in Glide just yet. I wanted to use a timer to rotate names in a list or remove names in a list when timers expire. It’s easy to do in google sheets but I want a countdown and instantaneous results which google sheets has a delay. But you would need timed events to be triggered.

1 Like

Happy 2021 to ALL,

This still bug me in 2020…

How do I implement logical AND in If-then-else? or What is best way to implement in Editor.

For example, we have two conditions and both must be true for it to be true. If either one condition is false then whole case will be false

My use case will be to check for two columns which are submitted by User. So if column A and column B is not empty then output should be True.

Thank you.

One thing you can do is this:

Let’s say I have a two columns, `Hair` and `Eyes`, and I want an IF…ELSE column to display special text if a row has both ‘Blonde’ Hair and ‘Blue’ Eyes, (perhaps maybe this is a nazi app? )

1. Make separate IF…ELSE columns for each column `Hair` and `Eyes` that return the values either `1` if true or `0` if false. e.g. IF `Hair = 'Blonde'` THEN `1` ELSE `0` and IF `Eyes = 'Blue'` THEN `1` ELSE `0`.
2. Make a third MATH column that multiplies the two columns from step one together.
3. The result is: if both columns from step 1 are true (ie `AND` statement), `1*1=1`. But if any value is false, `1*0=0` or `0*1=0`, the AND statement is false. Therefore your final IF…ELSE column can say, if that MATH column (the result of multiplying the two IF…ELSE columns that each return either 0 or 1) is 1, then both of the original columns satisfy the `AND` condition.
4 Likes

Sometimes you need to think about it differently. I like to call it ‘thinking backwards’. Sometimes it helps to look for the inverse of the value instead of looking for the actual value.

Using @avanavana’s example of wanting blonde hair and blue eyes, I would structure my If Then column like this.

IF Hair is not Blonde
THEN false

ELSE

IF Eyes is not Blue
THEN false

ELSE

true

This way, you will get a true result only if hair is blonde AND eyes are blue. The logic will continue through each condition until it finds a match. Otherwise it falls all the way through to the last ELSE.

In your case, it would be like this:

IF Column A is empty
THEN false

ELSE

IF Column B is empty
THEN false

ELSE

true

10 Likes

@Jeff_Hager
Thanks. Certainly made my day to look at inverse. Code is much neater also.

2 Likes

@avanavana thanks. this will work, but @Jeff_Hager’s suggestion makes the code so much neater.

1 Like

Hi!

Maybe the following is a trivial one but I can’t get over it:

I only want to check if a date (an order date) is within a certian period of time (>= Start AND <= End).

Does not work. Any Ideas?
And last, what’s the meaning of the “within” criteria? Shouldn’t it accept two dates, start and end?