IF(AND(..)issues

Hi there!
Iยดm having trouble with an expression that was working perfect.

Expression: IF(AND([Preg21]=โ€œSโ€,[Preg22]=โ€œSโ€],[Preg23]=โ€œSโ€,[Preg24]=โ€œSโ€,[Preg25]=โ€œSโ€),โ€œMes completoโ€," ")
The condition stops working.

0 20 1,043
20 REPLIES 20

Steve
Platinum 4
Platinum 4

In what way has it stopped working? Is there an error?

Be aware, too, of some non-intuitive behavior of the is-equal-to operator: if the value on the left side is blank, the exression is TRUE regardless of the value on the right side. For instance, if [Preg21] is blank, [Preg21]="S" is TRUE.

This has never made sense to me; in my mind the value of โ€œSโ€ is different than โ€œโ€ or even null! If you donโ€™t include an isnotblank() in there it doesnโ€™t work that way, and like Steve said: a blank [Preg23] will result in true just as if it had ACTUALLY met the criteria.

No sense to me.

Wait, is this true? I use these all the time and they seem to be behaving as I intuitedโ€ฆ

Indeed.

if you had this scenario:

[Preg23] = blank

that would result in true in your formula

Itโ€™s true. Also not intuitive, the opposite isnโ€™t true: "S"=[Preg21] is FALSE if [Preg21] is blank.

THIS is nice to know. Now I"m going on a formula hunting mission in all my active apps to switch things around.

Thanks @Steve!!!

Confirm first. Itโ€™s been a long time since I figured it all out. I may be misrembering.

2X_d_dcf596e4829730b5322c86ab5ac1cc10c73893e4.png

  • โ€œNew Virtual Column 1โ€ is a simple Y/N
  • โ€œNew Virtual Column 2โ€ you canโ€™t see - because it contains a formula where if New VC 1 is false, then New VC2 is blank (this gives us our blank field to play with)
  • โ€œColumn then criteriaโ€ shows exactly that, with a formula like this: [Column] = โ€œValueโ€ - looking for a value in New VC 2.
  • โ€œCriteria then columnโ€ shows it the other way around: โ€œValueโ€ = [Column]

Indeed, if you put an absolute value (or at least something that will never be blank) in the first position, then you can skip having to include an ISNOTBLANK() clause.

I have around 40 actions and reports that use this specifically, and now I learn it does the opposite of what it doesโ€ฆ

I have conditions where I use โ€œif([answer]=โ€œyesโ€โ€ฆโ€ where were [answer] blank, Iโ€™m expecting โ€˜falseโ€™ to be returnedโ€ฆ

I need a walk.

2X_2_212b2bd6c303d70ee67d8d3ad5afcc070ad51ace.gif

You are not alone. If there was one thing I could fix, this would be it.

Hey @Steve @Dengue_Evaluation @MultiTech_Visions
The ] was creating the error, also in Appsheet editor no error where shown.
I sopused it should show the error in the editorโ€ฆ?

Regarding of all what is in this chain of comments, I agree in what Steve said, but me be it will depend on the result that we are trying to fetch with the formula?
What I looking for is that If all the conditions are โ€œSโ€ is true, thatยดs it. If one doesnยดt mutch โ€œSโ€ is False, and also if any of the are blanck, is also False.
Iยดm I correct?

The expression syntax is somewhat loose. In this case, I suspect the parser saw "S"] as if it were "S]". There was no open bracket, so itโ€™s not expecting a close bracket, so treats it as arbitrary literal text.

Note that quotes are not strictly required around literal text values except to differentiate literals from reserved words and syntactic elements. But since thereโ€™s no good reference of such special elements, and itโ€™s really too much to expect the average app creator to be aware of such things, itโ€™s safest to quote all literal text as a matter of practice.

Try:

IF(
  ("SSSSS" = ([Preg21] & [Preg22] & [Preg23] & [Preg24] & [Preg25])),
  "Mes completo",
  " "
)

This is really clever.

This is really clever!
If I had orher vales for each column, should work right ?
Eg: If(โ€œSFT12โ€ฆโ€=[a]&[b]&โ€ฆ)),โ€xxโ€,โ€โ€zzโ€)

The idea behind @Steveโ€™s formula is to essentially concatenate together all the column values and compare that to a pattern that should match.

So as long as you know the pattern of values you want, then yeah it will work with anything.

What happens if you switch things around??? In an equality operation like this it shouldnโ€™t matter which is first (in regards to math)โ€ฆ so if you switch it to:

โ€œSโ€ = [Preg23]

would that get around it @Steve

Estas seguro que no serรก que en:
IF(AND([Preg21]=โ€œSโ€,[Preg22]=โ€œSโ€],[Preg23]=โ€œSโ€,[Preg24]=โ€œSโ€,[Preg25]=โ€œSโ€),โ€œMes completoโ€," ")
En [Preg22]=โ€œSโ€], hay un corchete de mรกs,
In the above mentioned condition theres an extra โ€œ]โ€ in the formula

Top Labels in this Space