This page will walk through an example of setting up a form to calculate a z-score based on a age in months, gender and weight.

First upload the following z-score table using the Manage Lookup Tables page. This table covers children between 0 and 60 months of age, but you can modify the table as needed for your project.

**Including Lookup Table Information in the Form**

Once we've defined a zscore lookup table, we need to reference it in our form. Edit the form XML and add an "instance" line that references the name of the table. You can place this above any existing instance tags in your form.

<instance id="zscores" src="jr://fixture/item-list:zscore"></instance> |

### Calculating the Z-Score

In your form, first add three questions, one for the gender, age in months and measured weight. (You can also load these from a case if you've previously captured them elsewhere). Note-- your answer options for the gender question MUST be "female" and "male" (not "m", "f" or "1", "2") to align with what is written in the z score look up table.

Then add a hidden value (zscore) to calculate the approximate z-score from the table. The calculation for this hidden value should be:

if(/data/weight < instance('zscores')/zscore_list/zscore[gender = /data/gender][month = /data/age]/sd3neg, -3, if(/data/weight < instance('zscores')/zscore_list/zscore[gender = /data/gender][month = /data/age]/sd2neg, -2, if(/data/weight < instance('zscores')/zscore_list/zscore[gender = /data/gender][month = /data/age]/sd1neg, -1,0))) |

Note: this calculation uses case properties named "gender", "weight", and "age." If you have named your case properties something else, you will need to change the reference above to the same name as your case properties.

This hidden value will be -3, -2, -1, or 0 which corresponds to the child being more than -3, -2 and -1 standard deviations from the mean. You can then use this hidden value for further calculations or display it back to the user.