Better and more consistent IF THEN logic

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 are 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 allows for ELSE logic if a condition is not true. There is no way to check if multiple conditions are true with and’s/or’s before moving on to the next ELSE condition.
  • Visibility conditions allow for AND/OR logic, but not a combination of both, so you are stuck with either everything true or only one of the conditions needing to be true. Sometimes you need condition A AND B to be true OR condition C AND D, but that’s not possible at the moment. It’s either all conditions or only one.
  • Custom actions allow a little more flexibility for all AND or OR logic combined with ELSE logic, but there is no way to combine AND’s and OR’s in the same condition check, so you have to build out several ELSE conditions so it can fall into the correct slot to fire off the correct actions. Sometimes you are building the same set of actions because you want A AND B to fire an action ELSE you want C AND D to fire the same action. Right now you have to duplicate the set of actions.

That’s three different methods of dealing with IF/THEN AND/OR logic and it’s not consistent between any of them. Custom actions handles it the best out of all three, still could be expanded to allow for combined AND/OR logic in the same condition check.

I have a situation where I was adding actions that did absolutely nothing (set column action that doesn’t set any columns) depending on a variety of different AND/OR conditions, but the number of ELSE conditions in the custom action was getting out of control and hard to follow. One small change would throw the entire thing out of whack, and if I need to add another condition, I had to try to mentally run scenarios through my head just to visualize where in the ELSE structure I needed to add the condition and would it cause other conditions to never fire. So instead I started to put some of the logic into an IF/THEN column, in the data, so I could end up with a single value to check in my custom action to determine if it should do anything or not. Problem is, the IF/THEN column follows a completely different procedure and has no AND/OR logic, so I’ve been trying to twist my mind around to make the right scenario fall through to the right conditions, based on several criteria, to return a TRUE/FALSE value that I can use in the custom action. Every time I get close, I find another loophole scenario that doesn’t set the correct value. I could probably break out the IF/THEN column into several IF/THEN columns, then combine those results into a final IF/THEN column, but that adds another level of complexity and confusion.

If would be so much easier if we could use logic similar to what any programming language uses:
IF a=b AND/OR c=d
ELSEIF a=c AND/OR b=d
ELSE e

To me, the oversimplification of IF/THEN handling and the inconsistencies of how it’s handled in different areas of Glide has caused some trouble. Instead of checking if a set of multiple conditions are true, sometimes we have to reverse that thought and check through a variety of false conditions and let the default ELSE be true. Most times it’s reasonably doable, but not intuitive to most people. Other times, we have to put IF/THEN columns on top of IF/THEN columns just to check if multiple conditions are true. Any time conditional logic become multifaceted with multiple possible conditions to check, then it gets really ugly and almost impossible to look back later and understand what and why you set it up that way. I think expanding on the IF/THEN logic to follow what a programmer would normally expect would actually make it easier for non-coders to understand.

I’ll try to expand with a bit of an example using my calculator app.

My number pad is an inline list of tiles. They all call the same custom action. What I’m trying to do is prevent users from typing a decimal more than once. Also, I’m trying to prevent them from typing a negative sign more than once…unless they have already inserted number after the negative sign, then the the negative will switch rolls and actually run the calculation, move the result to the left side and await input on the right side of the math operation. In addition to the negative sign serving two roles, I have to check if the user typed any numbers in, are they using any of the scientific calculations, did they type a negative or decimal already, etc, etc. There is a lot of things to check, but I also start to run into problems with the conditions messing up some of the other buttons that may or may not be allowed to be pressed. It’s a complicated structure that I’ve spend a few days on to clean up and make simple, but I keep finding loopholes. If I fix one thing, I break another. The IF/Then structure in code would be super simple but I just can’t find an elegant way to approach it without making a complete mess.

2 Likes

PREACH.

You didn’t even mention that if you create a really long and complex if then else column and need to change something or re-order it you have to re-create the entire column!

Also, the use of parentheses in the if then else conditions would be so beneficial!

  • If((a=b) AND (c=d)) OR (e=f) then true else false.

Love the idea of an elseif.

Would also love on the fly templates using tags of some kind:

  • if status=“new” then “Welcome, {nameColumn}” else “Welcome back, {nameColumn}“
9 Likes

Oh yes, that’s true as well. Not being able to insert a condition at the beginning or middle of an IF/THEN column is a pain. You have to rip the whole thing apart and rebuild it. Then if it still doesn’t work, you have to do it again. The way custom actions work is really close, but just missing a few things. At least there you can drag and drop conditions.

3 Likes

I think I turned this into a feature request/rant. Just frustrated because I’ve spent a lot of time on something that should be really simple.

6 Likes
Aside note : I like the "Experimental - Do not use to do your taxes !" :slight_smile: I wish I could use this excuse to justify my “mistakes”.

No mistakes here, take it in 2nd degree ! Amazing job by the way !

1 Like

hehe, thanks! Had to throw in a little humor since I’m still working out some bugs and calculations could be incorrect at times.

1 Like

Definitely not trying to hijack, but am I reading right that you can’t check multiple conditions with nesting? A lot of what I’m wanting to work on involves comparisons between six values to return the correct characteristic in a certain position. I’m currently doing checks by nesting IFs.

EX: IF(D$13=“TXT1”,‘SHEET’!CELL1,(IF(D$13=“TXT2”,‘SHEET’!CELL2,(… nesting six total checks

That will need to be performed in the sheet, instead or did I read you wrong? Disjointed reading due to work and home responsibilities make it likely I’ll miss things…

Something like what you want to do should be fine. It really depends on the situation. In my example, I’m doing some really off the wall things. Basically I have an inline list acting as buttons with some that can perform up to three different functions depending on a variety of different conditions. Some buttons do one thing, and some do other things. Definitely not typical.

In most other cases, I’ve always been able to accomplish the condition checks I need.

Using your example, it would just be a matter of IF ColD is TXT1 then Cell1, else If ColD is TXT1 then Cell1, etc. Pretty simple in that case.

2 Likes

Finally, I don’t feel alone about IF-Then logic and its limitation.

I have wished this feature/improvement for months as well

image

Saludos Jeff!

2 Likes

Also if then action would be nice, i would not need google sheets and scripts !

2 Likes

I have a case where the conditions possibilities in (compound) actions are too limiting.

First I want to scan a barcode then use this information to decide which route to go: 1) add a new row as the barcode is unknown 2) update the inventory item to being present 3) update the inventory to not being present

Further conditions could be relevant afterwards as well

3 Likes

The reorder issue is a massive pita.

As my apps get more complex I am also running into a lot of situations where I am building multiple ITE columns to do what (in theory) 1 would cope with happily.

There almost needs to be an ITE2 option as a column, because I’m not sure I can see a way they can build out on top of what they have without breaking the current version.

1 Like

I have the impression Glide is no longer prioritizing feature requests for app programmers. Listening to the CEO discuss the vision whilst at the same time watching an ever expanding list of important feature requests (many are repeat requests) I just get the impression the Glide team will not designate this one as a priority. IMHO this request points to a gaping hole in the Glide programing language. It should be a priority. Please tell us you agree. Tell us you will work on it as a priority with an ETA of X weeks (alongside a shortlist of others for full transparency).

Congrats on the shiny new suite of starter Apps for businesses like inventory management or real estate admin apps… but please deliver the long overdue feature requests, like these. What would be great is for you to present back the feature requests sorted by priority for your teams.

A billion programmers is a worthy vision but quality over quantity please.

5 Likes

Agreed. I love Glide and I hate to knock them because they are doing an awesome job…but many features just feel incomplete. We’ve gotten some new and awesome features over the past couple of years. Some have been useful, some have been purely eye candy, but some have also led to unconventional workarounds just to get them to function in a useful way. It feels to me like once a feature is released, it doesn’t get any additional attention and is considered good enough.

In my opinion, the basic core functionality hasn’t changed much in a long time and is lacking in many ways. I’d like to see more focus on building up and enhancing the existing features and functions instead of adding more new stuff that’s about 75% functional.

Some core functionality I’d really like to see some focus on:

  • String manipulation. Padding, Substring, Trim, Replace, etc. are crucial, but very hard to achieve in Glide.
  • Conditional relations, or at the very least, a conditional rollup. There is no way to possibly do a rollup of a value that fits within a limitless range of dates when comparing to a specific date value in each row. Sure you can filter on the front end, but that’s already too late when you need to filter for the rollup. (Relations don’t work when you need to find a range. They only work for exact matches, so a conditional rollup based on a value in each row is impossible. That’s why I think a conditional relation would open a whole lot of doors and cover a wide range of scenarios.)
  • IF logic is inconsistence throughout the builder. In some spots (like filters), it purely AND or OR logic, but not mixed. In others (like an IF column), it’s purely OR/Else logic, and yet in other spots, like Actions, it’s a mixture of AND or OR mixed with Else, but you have to duplicate Actions all over the place if you have to mix AND’s and OR’s (Plus there is no IF logic below the top level in actions. You also have to be very careful about order placement if you have several conditions to work with). I think proper and complex IF logic is absolutely vital to any application. It is the most vital piece of any programming language.
    Trying to do logic like, the below screenshots, in Glide can be an absolute nightmare when trying to conform it to the limited functionality we have…and this is the kind of stuff I do every day…so it seems like it should be trivial.

These types of problems are hard stops for me. Most of the feature requests that have gotten my vote are for these hard stop situations. If I can reasonably work around certain problems, then I don’t worry about it too much, because I can still get the job done. But, some of these core functions seem very crucial to me. Maybe it’s the programmer in me that tries to push the boundaries, but like I’ve said before, some of these things feel like they are so much easier to achieve with actual code. The simplified processes in Glide actually make some things harder to do and much more confusing to understand if you do get it to work. If there is a focus on creating apps for businesses, then I think core business logic should get a lot more attention.

I hate to rant, but these are the things I seem to fight with the most.

13 Likes

As a non coder I work from a completely different perspective, but interestingly have arrived at similar points.

Instead of knowing what is possible with code, I simply work on the idea that everything is possible with glide, until I discover it isn’t even with a work around.

I have abandoned a couple of projects because of these shortcomings, however I am still impressed with what is achievable. That being said, the projects I was working on appear (on the face of it) to be far simpler than those I have completed.

3 Likes

@Jeff_Hager spot on. If glide as they have stated wants to focus on internal business focused apps then they need to address these specific functionalities as you mention. It will make a huge difference - and will be expected by businesses.

And yes, some of the stuff you can do by workarounds but your app gets way more complicated and more difficult to maintain.

@david @mark this is a post that you should really consider understanding

A side node: adding if then else on each action in compound actions would also explode the flexibility and usefulness of compound action

4 Likes

Yes, Glide is really great for nocoders to Start moving from Idea to Reality; but the need for workarounds to perform simple operations (ex. multiselect choice component in the same datalist) is coming quite quickly.
Glide experts (many having coding background) can deal with it, but they are probably not in the 1 billion nocoders :slight_smile:

In addition, it would be great to know what features are on the short term roadmap (not clear whether voting for Feature Requests has any impact). It would enable to plan our apps, and avoid to use a complementary nocode platform: loss of focus for us to develop deeper our Glide skills, loss of revenues for Glide.

3 Likes

Hi, I have a doubt on the IF computed column in GDE.

After reading this thread, do I understand well:

  • IF computed column works as OR conditions?
  • The order of conditions is important? This I don’t understand; isn’t it contrary to the OR logic?

I don’t know if we’ll have an And/Or soon, but for sure it would be interesting to have more precisions in If → Then → Else Column - Glide Library on how this column works.

Thanks

1 Like

It depends. Is this for a visibility condition or an IF column?

If it’s an IF column, then the first condition that is true will return that value…so essentially an OR. If all of them are false, then it will fall through to the Else value.

If it’s an action, or visibility condition, then it depends on if you select the ‘And’ or ‘Or’ choice. Whatever you select will apply across all condition checks.

The problem I have is that you can’t intermix and and or. I have cases where I want to do something like this:

If (A=X and (B=Y or C=Z)) or E=F
ElseIf G=H
Else P

3 Likes

Thanks @Jeff_Hager.

Yes, it’s for an IF computed column in GDE, and I am trying to simulate an “AND” by putting the “not true” conditions in the IFs and the expected result in the ELSE.

1 Like