How to use multiple If statements

I want to display message based on Blood sugar level but highlighted if conditions are not executing in below expression. please correct me if I am doing any mistake

IFS(
([Blood Sugar] <= 130),
(“Normal”),
([Blood Sugar] > 130),
(“Low Risk”),
([Blood Sugar] > 175),
** (“Level 1”),**
** ([Blood Sugar] > 299),**
** (“Level 2”),**
** ([Blood Sugar] > 400),**
** (“Level 3”),**
TRUE,
[Blood Sugar]
)

Level 1 Level 2 Level 3 messages are not displaying

Could you please try

IFS(

([Blood Sugar] > 400),
(“Level 3”),
([Blood Sugar] > 299),
(“Level 2”),
([Blood Sugar] > 175),
(“Level 1”),
[Blood Sugar]
([Blood Sugar] > 130),
(“Low Risk”),
([Blood Sugar] <= 130),
(“Normal”)
)

I believe in your current expression anything above 130 returns true for the condition ([Blood Sugar] > 130 and as a result remaining following conditions are not evaluated.

1 Like

Suvrutt_Gurjar:

IFS(> > ** ([Blood Sugar] > 400),> ** (“Level 3”),> ** ([Blood Sugar] > 299),> ** (“Level 2”),> ([Blood Sugar] > 175),> ** (“Level 1”),**> [Blood Sugar]> ([Blood Sugar] > 130),> (“Low Risk”),> ([Blood Sugar] <= 130),> (“Normal”)> )

Thank you so much! worked perfectly

2 Likes

@Suvrutt_Gurjar
Hi,

I have BMI data and based on BMI value I need to show the following messages.

underweight: <18.5
normal: 18.5-24.5
pre-obese: 25-29.9
obese class I: 30-34.99
obese class II: 35-39.99
obese class III: >40

With my below expression few IF conditions were not executing, could you please help me out to correct the below expression

IFS(

([BMI] > 40),
(“Obese Class III”),

([BMI] < 18.5),
(“Under Weight”),

([BMI] >= 18.5),
(“Normal”),

([BMI] >= 25),
(“Pre-obese”),

([BMI] < 29.9),
(“Pre-obese”),

([BMI] <= 24.5),
(“Normal”),

([BMI] >= 30),
(“Obese Class I”),

([BMI] < 34.99),
(“Obese Class I”),

([BMI] >= 35),
(“Obese Class II”),

([BMI] <= 40),
(“Obese Class II”)

)

The IFS() expression is evaluated from the top down. Evaluation stops with the first condition that evaluates as TRUE. Consider the first few conditions of your expression:

IFS(
  ([BMI] > 40),
    (“Obese Class III”),
  ([BMI] < 18.5),
    (“Under Weight”),
  ([BMI] >= 18.5),
    (“Normal”),
  ([BMI] >= 25),
    (“Pre-obese”),

Suppose the BMI value being considered is 20. Th expression is evaluated like this:

  1. ([BMI] > 40): Is 20 greater than 40? No (FALSE). Continue to next condition.

  2. ([BMI] < 18.5): Is 20 less than 18.5? No. Continue to next condition.

  3. ([BMI] >= 18.5): Is 20 greater than or equal to 18.5? Yes (TRUE). Give Normal as the result and discontinue further evaluation of the IFS() expression.

  4. ([BMI] >= 25): Is 20 greater than or equal to 25? Who knows? This condition isn’t even considered because the previous condition was TRUE.

1 Like

Excellently explained @Steve

Hi @JAID

I believe you have raised this same question in another post thread.
My request to you is to restrict your one question to one thread. This is a very responsive community, so once you raise a query, typically be assured someone will respond to you.

This will eliminate two members working on your same query as I believe it happened with yet another question you posted today in another two threads. Also restricting to one thread will get you the best possible answer.

All the best with your app making.

1 Like

Sure Noted.

1 Like

Thanks for the detail explanation!!

I modified my expression accordingly and it worked perfectly.

2 Likes