BMI is often used as a measure of obesity when performing population analysis. It is easy to calculate and only requires a person’s Height and Weight. The basic formula is Weight in Kilograms divided by Squared Height in Meters ().

Sometimes when working with large datasets, you may find that you only have part of the picture. I have noticed that some clinical systems will just log the BMI and either the Height or Weight and not all three measurements. That missing measure can, however, be calculated if the other two are present.

For most uses, we are interested in having the Height in Centimetres (cm), Weight in Kilograms (kg) and BMI (kg/m²); So from this point on those are the units that I will be using.

Calculating the BMI from Weight (kg) and Height (cm), is easily worked out by dividing the Height by 100 to convert it to metres and using the standard formula: . Which in SQL is:

SELECT [BMI] = [Weight] / SQUARE([Height] / 100)
FROM ...

So to calculate the person’s Height (cm) from their Weight (kg) and BMI (kg/m²). The following formula will work: . Which is expressible in SQL as:

SELECT [Height] = SQRT([Weight] / [BMI]) * 100
FROM ...

And to calculate the person’s Weight (kg) from their Height (cm) and BMI (kg/m²). The formula is: . Which again in SQL is:

SELECT [Weight] = [BMI] * SQUARE([Height] / 100)
FROM ...

These can then all be combined in SQL to – where possible – fill in the blanks automatically:

SELECT
[Height] = ISNULL([Height], SQRT([Weight] / [BMI]) * 100 )
,[Weight] = ISNULL([Weight], [BMI] * SQUARE([Height] / 100))
,[BMI] = ISNULL([BMI] , [Weight] / SQUARE([Height] / 100))
FROM ...

### Like this:

Like Loading...