OR expression works like a AND expression in SHOW_IF

Hello all,

I'm having trouble with the OR() expression in SHOW_IF. It seems that appsheet sees this as an AND() expression, I have this problem in multiple forms. Is there a solution for this?

Previously this worked well.

Thanks in advance!

Solved Solved
0 32 496
2 ACCEPTED SOLUTIONS

@Willem 

Taking a suggest from @Marc_Dillon,  maybe it will help to describe to you in English what the expression is expected to do.

in your example you have an expression meant to be like this:

Show_If for [Col3] --- OR( ISBLANK( [col1] ) , ISBLANK( [col2] ) )

In english the result of this expression is: 

  • Show Col3 IF Col1 is blank
  • OR Show Col3 IF Col2 is blank
  • OR Show Col3 IF BOTH Col1 and Col2 are blank
  • OR DO NOT show Col3 if both have a value

The misunderstanding might be in the way OR's work.  OR's return FALSE only if ALL of the internal conditions are FALSE.   If any or all of the conditions are TRUE, the OR returns TRUE.

View solution in original post

AND( ISBLANK( [col1] ) , ISBLANK( [col2] )

View solution in original post

32 REPLIES 32

You need to elaborate.  What are your conditions and why do you think the OR() is being treated as an AND()?  

I have two choice menus when something is selected in one of those choice menus then another button has to disappear automatically. That's not happening. Only if I select something on both.

I've used several ways with show_if:
OR(ISBLANK[column_1], ISBLANK[column_2])
OR([column_1] = "", [column_2] = "")

It doesn't matter how I use it only if both are TRUE then the button disappears.

It seems so simple...

I've tried AND() instead of OR(), and it works!

AND() expression has become OR()

Who did that? I don't think this is intended. Or am I crazy... ๐Ÿ˜‰

And the worrying thing is that a number of my forms no longer work properly as a result

If AND() and OR() were not working correctly, it would impact ALL apps across AppSheet and would have been reported LOUDLY by the Community by now.  More than likely, you are making some assumptions about the expected results, when using ISBLANK() and testing for "", that are not accurate.  The column types you have defined and any Initial Values can impact the expected results of these  So, I can't provide any more insight without knowing those details.

To truly understand it and identify if there really is a problem,  I would recommend placing each portion of the expressions in their own column so you can see what result they contribute to the AND()/OR().

Never-the-less, I will run a quick test of my own to check it out and report back.

Ok, I have tested and both OR() and AND() seem to be working correctly in my use case.  See example below

I have Columns Test1, Test2, Test3, and Test4, all defined as Text columns.

  • Show_If expression for Test3:  OR(ISBLANK([Test1]), ISBLANK([Test2]))
  •      - i.e. Show Test3 if Test1 is blank or Test2 is blank or BOTH are blank

 

  • Show_If expression for Test 4:  AND(ISBLANK([Test1]), ISBLANK([Test2]))
  • - i.e. Show Test4 only if BOTH Test1 and Test2 are blank

If I enter a value in Test1, the Test4 column hides, as expected, since it is NOT the case that BOTH are blank.  However, Test3 still shows because Test2 is still blank.

If I continue and add a value to Test2, now both Test3 and Test4 are hidden, as expected.

Initial entry fields

Screen Shot 2022-05-17 at 8.44.44 AM.png

Test4 hides after entering a value in Test1

Screen Shot 2022-05-17 at 8.45.01 AM.png

Test3 also hides when values are present in both Test1 and Test2

Screen Shot 2022-05-17 at 8.45.22 AM.png

Thank you for the extensive testing.

My apologies: I forgot to mention that these are ENUM fields.

I'm going to build a test app to see if the problem is the same (or not)

SHOW_IF of kolom_3: OR([kolom_1] = "", [kolom_2] = "")

I have now created a new app but the same problem persists (see the screenshots below)

Willem_0-1652792952284.png

Willem_1-1652793010126.pngWillem_2-1652793039877.pngWillem_3-1652793120029.png

 

This looks obviously a glitch to me.  Better to report to support for help (correctly a bug report to fix this problem.)

There is no issue with OR or AND, they are working exactly as they should be. The issue is with your logic.

You seem to be thinking that "show_if" is actually "hide_if". It's not.

In your test example, you're telling the kolom_3 field to be visible if either 1 or 2 is blank. That means it will NOT be visible is neither are blank, i.e. when you select something in both 1 and 2 fields, 3 is hidden.

I tested quickly and this is potentially a bug. I passed and(isblank([col1]),isblank([col2])) expression to [col3] to show if.

Once the col1 is set a value, then col3 was hidden, while and(isblank([col1]),isblank([col2])) returns false.

What you described is exactly how the logic should be working. What is the potential bug?

2022-05-17_23-23-54.gif

.

and(isblank([col1]),isblank([col2])) is passed to VC to test to see what is the return.

The same expression is passed to show if for Enum. While the same expression returns false. then the Enum is hidden.

For me, a bug, while you believe it is not. I wont argue with that point though with you.

 

Yes, when the show_if condition is false, the column is hidden. Your example is still working exactly as it should.

Again, it's SHOW_if, not HIDE_if.

If you want the field hidden when both are blank, that's equivalent to showing the field when either one has a value, so:

OR( ISNOTBLANK( [col1] ) , ISNOTBLANK( [col2] ) )

 

Haha my logic is not correct, everyone has shouted all my life ๐Ÿ˜‰

I created a bug report, only they refer me back to the forum. It's about the And and OR Expression, it's not right.

I now have an example with and:

Willem_0-1652797132314.png

Willem_2-1652797171612.png

 

 

Maybe if you can describe in plain language what you're trying to accomplish, someone can suggest a show_if formula for you to use.

Isblank([Col1]) and [Col1]="" returns the same result. For me, it is a bug (if not a bug, it is a glitch)


@Koichi_Tsuji wrote:

Isblank([Col1]) and [Col1]="" returns the same result. For me, it is a bug (if not a bug, it is a glitch)


There was  a lot of discussion last year about how these values should be treated (and defaulted).  What you are seeing is the resulting design decision by AppSheet.  It is not a bug nor a glitch but a conscience decision by the developers to treat these equally.

Personally, I don't see any reason why these should be different.  In our implementations we need to be able to "blank" things out.  We do that by assigning "" (empty string).

@Willem @Koichi_Tsuji @Marc_Dillon 

In example screenshots, the values you are testing against do NOT seem to be "" (empty string. 

They instead seem to be " " (blank). 

Blank versus empty string are two different things as far as the expression is concerned in AppSheet.

Change the value to ISBLANK() or "" and you should see the results you expect.

 

isblank([col]) brought the same story at the end.

If I start using AND() as an OR () it just works and I get the result the way I want it. But I don't think that's the intention.

OR () = Any
AND () = ALL

And that is exactly the other way around with show_if.

So this expression is giving you the result that you want:

AND( ISBLANK( [col1] ) , ISBLANK( [col2] ) )

?

That's saying to show the column only if both other columns are blank.

That's equivalent to hiding the column if either 1 or 2 has any value.

It is not a story. Appsheet not behaive in that way currently, as far as my test is concerned. 

@Koichi_Tsuji 

I know you, from this Community, to be a smart, honorable person with attention to detail.  Please carefully re-evaluate your understanding of how this particular expression should be behaving. 

This is logic and there can be only ONE right answer.  @Marc_Dillon is correct in his analysis.  It is behaving correctly and your posted example actually proves it.

The issue is not in the logic but in the understanding of how it should work.  But this is understandable  as sometimes even those of us who have worked in logic expressions for decades get tripped up on even some of the simplest expressions.

Yes! But he react as an OR(). 

It now works like this:
AND() When one or all columns are no longer empty, the button disappears.
OR() When all columns are no longer empty (with one column empty nothing happens) then the button disappears
It's very confusing especially because it seems to be something simple.

ISBLANK or "" (empty string) is not the question for me.

AND() expression works as OR() expression and OR() works as AND() expression

>>"AND() expression works as OR() expression and OR() works as AND() expression"

No, it doesn't.

For the second time, describe in plain language what you are trying to accomplish.

EDIT:

Sorry, re-reading the thread you said it in your 2nd message:

>>"I have two choice menus when something is selected in one of those choice menus then another button has to disappear automatically."

You want col3 to be hidden once any value has been entered into either col1 or col2. So your HIDE_if (if such a thing existed) would be:

OR( NOT( ISBLANK( [col1] ) ) , NOT( ISBLANK( [col2] ) ) )

Showing is the negation of hiding, so we need to negate the above logical statement and put that in as the SHOW_if. That would be:

AND( ISBLANK( [col1] ) , ISBLANK( [col2] )

Please see the article I posted below to understand how that negation works.

@Willem 

Taking a suggest from @Marc_Dillon,  maybe it will help to describe to you in English what the expression is expected to do.

in your example you have an expression meant to be like this:

Show_If for [Col3] --- OR( ISBLANK( [col1] ) , ISBLANK( [col2] ) )

In english the result of this expression is: 

  • Show Col3 IF Col1 is blank
  • OR Show Col3 IF Col2 is blank
  • OR Show Col3 IF BOTH Col1 and Col2 are blank
  • OR DO NOT show Col3 if both have a value

The misunderstanding might be in the way OR's work.  OR's return FALSE only if ALL of the internal conditions are FALSE.   If any or all of the conditions are TRUE, the OR returns TRUE.

Please study this:

https://www.math.toronto.edu/preparing-for-calculus/3_logic/we_3_negation.html

Hiding a column is the opposite, or "negation" of showing a column.

I'll try to describe it:
DO NOT show COL3 IF COL 1 has a value OR
DO NOT show COL3 IF COL2 has a value OR
DO NOT Show COL3 IF COL 1 and COL 2 has a VALUE
SHOW COL3 only when COL1 AND COL2 is empty

The COL3 Show_IF Syntax is: OR(ISBLANK([COL_1]), ISBLANK([COL_2]))
and that doesn't work.
The syntax: AND(ISBLANK([COL_1]), ISBLANK([COL_2]))
Does exactly what I want, I don't get it

Can you do something with this?

AND( ISBLANK( [col1] ) , ISBLANK( [col2] )

Haha, I get it! How stupid, but good to write it out, then you also do the negotiation the other way around (not negatively). And that's exactly where the logic is. Is it weird that I look so strange at that?

Thanks a lot, to all!

Top Labels in this Space