Expressions IF, AND OR?

Hi

I need some advice. I have tried AND, OR but nothing is seeming to work or maybe I am not understanding the language.

I have 3 columns [Systolic],[Diastolic] and [BP Outcome]

In [BP Outcome] I am trying to set the following parameters:

If [Systolic] < 130 AND [Diastolic] < 85 ” Low”

[Systolic] >= 130 OR <140, AND [Diastolic] >= 85 OR <90, “Moderate”

[Systolic]>=140, AND [Diastolic] >= 90, “High”)

Can anyone shed any light on where I am going wrong, In simple terms please, I am not a coder…

IFS(
   AND(
      [Systolic]<130,
      [Diastolic]<85
   ),
   "low",
   OR(
      [Systolic]>=130, 
      AND(
         [Systolic]<140,
         [Diastolic]>=85,
         [Diastolic]<90
      )
   ),“Moderate”,
   AND(
      [Systolic]>=140,
      [Diastolic]>=90
   ),“High”
)

https://support.google.com/appsheet/answer/10107912?hl=en

Note that when using IFS(), if it goes all the way through and gets no matches it returns “”

Simon@1minManager.com

1 Like

Hi @Gardener76

What about:

IFS(
  AND(
      [Systolic] < 130,
      [Diastolic] < 85
  ), 
    "Low",
  AND(
    OR(
      [Systolic] >=  130,
      [Systolic) <140
    ), 
    OR(
      [Diastolic] >= 85 ,
      [Diastolic]<90
    )
  ), 
    "Moderate",
  AND(
    [Systolic]>=140,
    [Diastolic] >= 90
  ), 
    "High"
)

For reference:

IFS() - AppSheet Help

AND() - AppSheet Help

OR() - AppSheet Help

3 Likes

You are using OR where AND should be, you want the value meet BOTH conditions not just one.

I would use an IFS() function. It would be like this (can’t be any simpler than copy paste!):

IFS(
     AND([Systolic] < 130, [Diastolic] < 85), "Low",
     AND([Systolic] >= 130, [Systolic] < 140, [Diastolic] >= 85,[Diastolic] < 90), "Moderate",
     AND([Systolic] >= 140, [Diastolic] >= 90), "High",
     TRUE, "Unknown"
)     

I added a default case “Unknown” should any conditions not be met, Maybe its not possible but what should happen if , [Systolic] >= 140 AND [Diastolic] < 85?

4 Likes