This guide will walk you through creating a BMI (Body Mass Index) calculator using variables and logic in your form.
You can use variables to store user input (weight and height), calculate the BMI, and dynamically display different messages based on the result.
🧩 Template:
For a ready-made solution, you can use this BMI Calculator Template to easily set up BMI calculation and customize it for your needs.
Step 1: Create fields for weight and height
Add a number field for weight with the ID
weight
.Add a number field for height with the ID
height
.
These fields will be used to collect user data for calculating the BMI.
Step 2: Add variable fields to calculate BMI
Create the "Height" variable
Field Type: Variable
Type: Formula
ID:
heightm2
Formula:
height * height
Max number of decimal places: 0
This variable calculates the square of the height value (m²).
Create the "BMI" variable
Field Type: Variable
Type: Formula
ID:
bmivalue
Formula:
weight / heightm2
Max number of decimal places: 0
This variable calculates the BMI using the weight and the height squared (from
heightm2
).
Key formula:
Height Squared:
heightm2 = height * height
BMI Calculation:
bmivalue = weight / heightm2
This setup ensures that the bmivalue
is dynamically calculated based on the user's inputs for height and weight.
Step 3: Add different ending pages
Before setting up logic, create separate ending pages for each possible result (e.g., Underweight, Normal weight, Overweight, Obese). In this case, we've added four different success messages for each BMI category.
Ending Page 1: Underweight
Ending Page 2: Normal weight
Ending Page 3: Overweight
Ending Page 4: Obese
Make sure to give each ending page a title in the right-side menu (e.g., "Underweight", "Normal weight", etc.) to make it easier to refer to them later when setting up logic for redirection.
📝 Additional Insights:
For more information on setting up multiple ending pages with logic to redirect users based on their responses, check out our article on How to add multiple ending pages with redirect logic.
Step 4: Set up logic to categorize BMI results
Open the Logic tab: Go to the Logic section in the form editor and click the Advanced Logic button.
Set conditions: Scroll down to the end of your logic page. Add conditions under the "On Submitting The Form" section to determine which ending page should be displayed.
Create conditions for each BMI category: Add conditions based on the calculated BMI value to redirect users to the appropriate success message.
If BMI is less than 18.5, redirect to the Underweight ending page.
If BMI is between 18.5 and 24.9, redirect to the Normal weight ending page.
If BMI is between 25 and 29.9, redirect to the Overweight ending page.
If BMI is greater than 30, redirect to the Obese ending page.
Step 5: Display the BMI result
Use answer piping: In the message for each ending page, insert @bmivalue
using answer piping. This will dynamically display the user’s calculated BMI value in each message.
For example:
Underweight: "Your BMI is @bmivalue, and you are underweight."
Normal: "Your BMI is @bmivalue, and you have a normal weight."
Overweight: "Your BMI is @bmivalue, and you are overweight."
Obese: "Your BMI is @bmivalue, and you are obese."
This ensures that the BMI result is shown directly in the relevant success message.
Step 6: Test the BMI calculator
Preview the form to ensure that the BMI is calculated correctly and that the appropriate message is displayed based on the user’s input.