Automatically calculating BMI from Height and Weight values in a form

Hi, I’m trying to compute BMI (body Mass Index) from a “Height” field and “Weight” in a form. I have defined the “Height” and “Weight” fields as Numbers in the database. I also want to save the resulting BMI back into the database. I tried using Custom formula but it does not allow me to select the “Current Height” or “Current Weight” in the form when building the formula. It only show me Sum, Average, Min, Max Etc for “Height” and “Weight” field. How do I compute BMI do this from a Height value and Weight Value that is enter in a form? Thanks

Hi & welcome to the Adalo community!

I’d use a custom form. Create the components manually and for the BMI, save the formula like I’ve created below:

1 Like

Thank you for the prompt response and guidance, Erik. Much appreciated! I tried your suggestion and it works. Regards, Praveen

Erik, I have a follow-up question. I have successfully computed BMI based on Height and Weight and stored it in the database. Thanks for your guidance. I now want to update another field in the database based on the BMI value. Eg; If BMI is > 25 and < than 30 I want to store the value of “Overweight” and if BMI is > 30 I want to store the value of “Obese” in the status field of the DB. Thanks, Praveen

I’d do this as a two step process (easiest) although you might be able to do this in one step.

  1. Have the user submit the form and capture their BMI using the formula and process above.
  2. show a modal with that information and their status (obese, etc). I’d list all three statuses and use conditional visibility to show the correct value.
  3. When the user clicks submit on the modal, use 3 conditional actions on the button filtered to less than, between, greater than (for your respective statuses)

It’s best to do this in two steps because you need to capture the BMI first in the logged in user collection. You could probably run two update user actions on the same button too. Give it a try and see what works.

2 Likes

Awesome! …it worked. I added 3 conditional updates on the SAVE button and the correct status value got saved in the DB based on the rule. Thank you Erik…you are the best!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.