# "And Condition" and "Or Condition" together in a visibility component

**URL:** <https://community.glideapps.com/t/and-condition-and-or-condition-together-in-a-visibility-component/47389>\
**Category:** Project Showcase\
**Created:** [August 21, 2022, 6:09pm UTC](https://community.glideapps.com/t/and-condition-and-or-condition-together-in-a-visibility-component/47389 "2022-08-21T18:09:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ShantanuIyengar](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/shantanuiyengar/32/35546_2.png) [@ShantanuIyengar](https://community.glideapps.com/u/ShantanuIyengar)\
**Post date:** [August 21, 2022, 6:09pm UTC](https://community.glideapps.com/t/and-condition-and-or-condition-together-in-a-visibility-component/47389/1 "2022-08-21T18:09:11Z")

</div>

Hey guys!  
So it may sound silly!  
Many of us might have faced this issue before!

We have an element that is to be visible by Role A or Role B and the signed in user should satisfy one more condition.

So the problem is:  
Element Visibility is ((role = “Role A” or role = “Role B”) and verified = isChecked)  
Any suggestions on how to achieve this!

P.S. I already have an answer, but this is somewhat of a challenge to the community!  
I’ll post the answer in a day’s time and let the challenge be here till then!

Cheers!

Note: No computed columns to be added

---

<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:** [August 21, 2022, 6:45pm UTC](https://community.glideapps.com/t/and-condition-and-or-condition-together-in-a-visibility-component/47389/2 "2022-08-21T18:45:43Z")

</div>

My fallback would be to us a single IF column to return a true/false value for simplicity sake, and then use that for the visibility condition, since it is slightly more flexible than building a visibility condition.

But, since you threw out the challenge to not use any additional computed columns, I have a couple of ideas:

* * *

The first idea would require knowing all other potential roles (hoping that they remain fairly static and you don’t add new roles in the future).

So let’s say you have Roles A,B,C,D. I would structure the visibility conditions with AND, so all conditions must be true. This is how I would do it purely with a visibility condition and no computed columns.

IF Role != C  
AND  
IF Role != D  
AND  
IF verified = isChecked

The only problem is that it’s not scalable if new roles are added, so all visibility conditions would have to be updated each time a role is added that should not make the component visible.

* * *

The second idea, which is a lot simpler, is to structure your visibility condition like this:

IF Role is included in ‘Role A,Role B’  
AND  
IF verified = isChecked

I’m leary about using ‘is included in’ or ‘includes’ only because of the potential for it to pick up unintended matches, but if you have good control over the potential values, then there shouldn’t be a problem.

---

<div class="post-metadata">

**Author:** ![ShantanuIyengar](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/shantanuiyengar/32/35546_2.png) [@ShantanuIyengar](https://community.glideapps.com/u/ShantanuIyengar)\
**Post date:** [August 21, 2022, 7:09pm UTC](https://community.glideapps.com/t/and-condition-and-or-condition-together-in-a-visibility-component/47389/3 "2022-08-21T19:09:56Z")

</div>

The second idea is actually the perfect way to execute that!  
Is included in works perfectly with arrays of information

🥳

Solution: [https://media.discordapp.net/attachments/836261617028300800/1010970141435105290/AndOrConditionTogether.mp4](https://media.discordapp.net/attachments/836261617028300800/1010970141435105290/AndOrConditionTogether.mp4)

---

<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:** [August 21, 2022, 7:16pm UTC](https://community.glideapps.com/t/and-condition-and-or-condition-together-in-a-visibility-component/47389/4 "2022-08-21T19:16:27Z")

</div>

Still curious if anybody else has other ideas. I’m always willing to learn. 🙂

---

<div class="post-metadata">

**Author:** ![gvalero](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gvalero/32/1037_2.png) [@gvalero](https://community.glideapps.com/u/gvalero)\
**Post date:** [August 21, 2022, 10:05pm UTC](https://community.glideapps.com/t/and-condition-and-or-condition-together-in-a-visibility-component/47389/5 "2022-08-21T22:05:05Z")

</div>

> [@Jeff\_Hager](#):
>
> IF Role is included in ‘Role A,Role B’  
> AND  
> IF verified = isChecked

Interesting!

More interesting is that you can use any character/symbol as “separator” and the logic still works… WTF! 🙃

I mean, theses cases/syntaxes can be used:

> IF Role is included in ‘Role A/Role B,Role C’  
> AND  
> IF verified = isChecked

… or this one

> IF Role is included in ‘Role A Role B; Role C’  
> AND  
> IF verified = isChecked

but there will be problems if our logic finds a match on some string (the Jeff´s concern).  
E.g.:  
If you have these Roles names: **Admin** , **Admin-EN** , **Admin-SP** and **Full Admin**

the logic bellow will fail because the _ **Admin** _ word is contained in these 4 cases:

> IF Role Type is included in ‘Admin’  
> AND  
> IF verified = isChecked

but anyway, it’s good tip if we do all this very carefully and don’t use words with similar letters.  
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:** [August 22, 2022, 1:30am UTC](https://community.glideapps.com/t/and-condition-and-or-condition-together-in-a-visibility-component/47389/6 "2022-08-22T01:30:36Z")

</div>

> [@Jeff\_Hager](#):
>
> Still curious if anybody else has other ideas. I’m always willing to learn.

As fas as I’m concerned, the if-then-else column solution is the best, and the one I will always use once I have more than a single condition. It’s the easiest to maintain - especially if the condition needs to be applied to multiple components - and it doesn’t violate my personal mantra of keeping as much logic as possible in the data editor.

I agree with your comments regarding the `is included in` option. I consider that fragile and easily broken, and I would avoid it.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)\
**Post date:** [August 23, 2022, 1:31am UTC](https://community.glideapps.com/t/and-condition-and-or-condition-together-in-a-visibility-component/47389/7 "2022-08-23T01:31:01Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
