# General calculation templates

• ## Check if all fields are filled in

If you want to check whether certain fields are filled in, you can use the template below. In this template, there are 2 fields:  Variable name Field label dem_pat_gender Gender dem_pat_yob Year of Bi...

• ## Converting weight and length units

Sometimes you need to convert the units of a given measure to keep a unified format across your study. These conversions are usually inches or feet to centimetres and pounds to kilograms, or vice-vers...

• ## Rounding numbers

If you want to round numbers to an X number of decimals, you can use the templates below. Change the number after 'toFixed(' to change the number of decimals. To round up to 0 decimals, use: var num =...

• ## Check if all fields are complete (and list empty fields)

With this calculation template, you can check whether a group of fields have been filled in or are empty. If certain fields are not filled in, they will be listed in the calculation. In this example, ...

• ## Allow data entry with different measurement units

You can enter data with different measurement units, and standardise all collected data with the same measurement unit with a calculation. For example, let's say that you are collecting the medication...

• ## Calculating with grids: numbers

The instructions described in the article Calculate with grid fields  renders the objects in string (plain text). If you want to do mathematical operations with numbers, you will need to convert that ...

• ## Calculating with grids: dates

Following the basics described in Calculate with grid fields, the current article explains how to calculate with grids when the cells have been defined as date. Once again, the first step is to parse ...

• ## Validate grid field values

Calculation fields can be used to validate values in the grid field. For example, this template validates the values entered in the first and second columns of the first row. var obj = JSON.parse('{gr...

• ## Calculate the median of a set of values

While the average is the result of performing some mathematical operations, the median is employed more as descriptive of the data set and usually involves no mathematics.  The median is thus defined ...

• ## Adding a dependency on a grid field

Calculation fields can be used to make other fields dependent on certain values added to the grid field. For example, this template outputs 1 if the data entered into the Row one, Column 1 is 'Yes' (e...