# How to support nested logical comparison?

**URL:** <https://community.glideapps.com/t/how-to-support-nested-logical-comparison/37408>\
**Category:** Ask for Help\
**Created:** [January 19, 2022, 2:39pm UTC](https://community.glideapps.com/t/how-to-support-nested-logical-comparison/37408 "2022-01-19T14:39:18Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![remoteworker.id](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/remoteworker.id/32/36396_2.png) [@remoteworker.id](https://community.glideapps.com/u/remoteworker.id)\
**Post date:** [January 19, 2022, 2:39pm UTC](https://community.glideapps.com/t/how-to-support-nested-logical-comparison/37408/1 "2022-01-19T14:39:18Z")

</div>

I just realize for visibility, glideapps is somewhat too simple for complex cases (or actually it’s just simple case really). So, I want to show an information but with these conditions:

- Payment Send is Empty (not yet sending a payment)  
AND
- Level is 1 OR 2 OR 4.

At the moment, there is only one AND or OR in visibility, so my code will always change into either:

Payment Send AND Level == 1 AND Level == 2 AND Level == 4  
or  
Payment Send OR Level == 1 OR Level == 2 OR Level == 4

Which those are not correct at all.  
I hope we can have true comparison here 🙂  
I really love to see glideapps getting more recognition and implementing a true logical statement comparison will be one way to go.

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:** [January 19, 2022, 2:59pm UTC](https://community.glideapps.com/t/how-to-support-nested-logical-comparison/37408/2 "2022-01-19T14:59:59Z")

</div>

You can do this by first creating an if-then-else column, and then use the if-then-else column as the filter. The logic for the if-then-else column will be:

- If Payment Send is not empty, then blank
- If Level equals 1, then `true`
- If Level equals 2, then `true`
- If Level equals 4, then `true`

Then your visibility condition will be "where if-then-else column is `true`"

---

<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:** [January 19, 2022, 5:01pm UTC](https://community.glideapps.com/t/how-to-support-nested-logical-comparison/37408/3 "2022-01-19T17:01:53Z")

</div>

Another possible alternative for the filter itself:

- If Payment Send is not empty  
AND
- If Level is included in 124

---

<div class="post-metadata">

**Author:** ![David\_Gabler](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/david_gabler/32/44332_2.png) [@David\_Gabler](https://community.glideapps.com/u/David_Gabler)\
**Post date:** [January 19, 2022, 5:33pm UTC](https://community.glideapps.com/t/how-to-support-nested-logical-comparison/37408/4 "2022-01-19T17:33:09Z")

</div>

I like the workarounds, and have used them (clever Jeff – had not thought that), but I agree that we need the ability for more complex comparisons. For example, some of my comparisons cross the lines between two tables, and the workarounds do not work in those cases. I’d have to go back over my logbook to see exactly which ones I abandoned as simply not doable, but they typically had to do with trying to make something work differently for an ADMIN user (flag in user record).

---

<div class="post-metadata">

**Author:** ![Eric\_Penn](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/eric_penn/32/73888_2.png) [@Eric\_Penn](https://community.glideapps.com/u/Eric_Penn)\
**Post date:** [January 19, 2022, 5:42pm UTC](https://community.glideapps.com/t/how-to-support-nested-logical-comparison/37408/5 "2022-01-19T17:42:06Z")

</div>

If an important flag exists in a second table you could use a relation + lookup to bring it into your source sheet. Then use the new lookup column in your ITE logic, component filter, etc…

---

<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:** [January 19, 2022, 7:05pm UTC](https://community.glideapps.com/t/how-to-support-nested-logical-comparison/37408/6 "2022-01-19T19:05:49Z")

</div>

☝What he said!

Never say anything is impossible. I don’t live by that philosophy.

But yes, you are preaching to the choir:

> [@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:** ![David\_Gabler](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/david_gabler/32/44332_2.png) [@David\_Gabler](https://community.glideapps.com/u/David_Gabler)\
**Post date:** [January 19, 2022, 8:32pm UTC](https://community.glideapps.com/t/how-to-support-nested-logical-comparison/37408/7 "2022-01-19T20:32:12Z")

</div>

> [@Eric\_Penn](#):
>
> If an important flag exists in a second table you could use a relation + lookup to bring it into your source sheet. Then use the new lookup column in your ITE logic, component filter, etc…

I ran into a situation yesterday where a relation would not solve a problem, because I needed to look at a flag that was set, but not on the owner of the current record. You see, I am not using true row owners but simulating them because many users can share a record – but roles doesn’t help me here, either, because the user themselves can select what rows are available to them. Thus, no matter how I hammered on relations and lookups, I always ended back up at square one.

Believe me, I use relations all over and know how they work. They just don’t always answer the problem. My current user is an admin, but not the owner of the row, and I had several conditions that had to be met for a regular user to do something (so there was this _AND_, and and and), and I simply needed to add an _OR_ if (logged in user) ADMIN is true. Seemingly simple enough, but without the ability to do complex logic without having to resold to relations, just isn’t always possible.

---

<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:** [January 19, 2022, 8:40pm UTC](https://community.glideapps.com/t/how-to-support-nested-logical-comparison/37408/8 "2022-01-19T20:40:00Z")

</div>

Maybe I need to see more information, but from what you explained, it seems that you could have two IF columns. One to check all of the AND conditions for a user and return true if they have access, and anoth IF column to check if that user IF value is true ELSE IF the signed in user is Admin. The combination of IF columns then act as an AND/OR.

---

<div class="post-metadata">

**Author:** ![remoteworker.id](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/remoteworker.id/32/36396_2.png) [@remoteworker.id](https://community.glideapps.com/u/remoteworker.id)\
**Post date:** [January 19, 2022, 9:11pm UTC](https://community.glideapps.com/t/how-to-support-nested-logical-comparison/37408/9 "2022-01-19T21:11:27Z")

</div>

Thanks all for the propose solution! Give me lots of insight for my future in Glide.

But I just realize how to use “is included in” like what Jeff said, and for me it is the most simplest solution, so I use this.

And upon finding solution for this problem, I just realize showing information for each level is still better whether user already send their payment or not. So, the conditional for “Payment Send” has been removed.

The code is now simpler, thanks to Jeff solution of using “is included”.  
So it is now, “Show component when Level is included in 1,2,4”

I am just guessing it’s comma separated list. It works anyway!  
Thanks!

---

<div class="post-metadata">

**Author:** ![David\_Gabler](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/david_gabler/32/44332_2.png) [@David\_Gabler](https://community.glideapps.com/u/David_Gabler)\
**Post date:** [January 19, 2022, 9:26pm UTC](https://community.glideapps.com/t/how-to-support-nested-logical-comparison/37408/10 "2022-01-19T21:26:42Z")

</div>

> [@Jeff\_Hager](#):
>
> The combination of IF columns then act as an AND/OR.

Yes, and I do stuff like that, also. Sometimes it’s enough to make my head hurt!  
Here are the columns I need to examine to see if a particular user should see a particular row:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/7/6/76f6ca84ce6aa0022d6b202e6685588663166823.png)

---

<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:** [January 19, 2022, 9:46pm UTC](https://community.glideapps.com/t/how-to-support-nested-logical-comparison/37408/11 "2022-01-19T21:46:16Z")

</div>

> [@remoteworker.id](#):
>
> am just guessing it’s comma separated list. It works anyway!

I don’t think it matters. It’s just looking for matching text anywhere within the whole string of text. Seperating by commas is good practice though if you have double digit numbers or other cases where it could inadvertently find a match that you didn’t intend it to find.

---

<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:** [January 19, 2022, 9:56pm UTC](https://community.glideapps.com/t/how-to-support-nested-logical-comparison/37408/12 "2022-01-19T21:56:17Z")

</div>

If I recall, it’s ultimately your ‘Show In List’ column that’s a culminating of all the columns to the left, correct? I’m just thinking that you could have another IF column that checks if Show In List is true then true, else if Admin then true, else false.

Sorry, I know you didn’t explicitly bring this up and you were just talking about IF structure in general. I was just curious about your scenario. I can drop it now. But yes, formulating complex IF statements in glide isn’t always fun or easy.

---

<div class="post-metadata">

**Author:** ![David\_Gabler](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/david_gabler/32/44332_2.png) [@David\_Gabler](https://community.glideapps.com/u/David_Gabler)\
**Post date:** [January 19, 2022, 10:26pm UTC](https://community.glideapps.com/t/how-to-support-nested-logical-comparison/37408/13 "2022-01-19T22:26:03Z")

</div>

> [@Jeff\_Hager](#):
>
> ‘Show In List’ column

Yes, and the “Show English” is what gets displayed in the list so they can toggle the viewable setting. That ability to toggle is what complicated it even more.

No need to drop it, I was just responding that generally, it would be neat if they implemented a regular expression column that spits out true or false. Or perhaps they have it and I’ve just missed that.

---

<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:** [January 19, 2022, 10:39pm UTC](https://community.glideapps.com/t/how-to-support-nested-logical-comparison/37408/14 "2022-01-19T22:39:28Z")

</div>

I haven’t messed with most of the plugins. I think there are some Regex related ones, but I’m not sure if they would work in this particular context. I have used the javascript plugin a handful of times though. If you really wanted to go all in, you could just pass your parameters into the javascript column, perform your IF logic there and return an ultimate true or false value.

---

<div class="post-metadata">

**Author:** ![David\_Gabler](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/david_gabler/32/44332_2.png) [@David\_Gabler](https://community.glideapps.com/u/David_Gabler)\
**Post date:** [January 19, 2022, 11:10pm UTC](https://community.glideapps.com/t/how-to-support-nested-logical-comparison/37408/15 "2022-01-19T23:10:05Z")

</div>

Thanks!

Yes. I’ve implemented other people’s JS. I don’t know JS well enough.
