I recently started with Power Apps and one of the very first app I am building is a Body Mass Index (BMI) calculator. I was able to set it to automatically convert from Kg to pounds and cm to feet.
The problem I am facing now is outputting the result using If
or Switch
statement to show the BMI categories:
BMI Categories:
Underweight = <18.5
Normal weight = 18.5–24.9
Overweight = 25–29.9
Obesity = BMI of 30 or greater
The formula I intend to use is
BMI = 703* (weight/(Height^2))
This is the logic I used
Set(VarResult,If(tx1.Text/(tx2.Text^2)*703)=<18.5,"underweight")
if(VarResult>18.5,"Normal")
if(VarResult>=24.5,"Overweight")
if(VarResult>30, "Obese"))
Thank you for assisting with the if statement, the error is with the calculation after solving the if statement. The correct logic is
With(
{res:Value(tx1.Text)/(Value(tx2.Text)^2)*10000},
If(
res>= 30, "Obese",
res> 25 && res< 29.9, "Overweight",
res> 18.5 && res< 24.9, "Normal",
res<= 18.4, "Underweight"
)
)
Thank you all.