You can use the following function types in your fields' display text or in the values of your skip or validation logic: 

  • Select functions
  • Repeat functions
  • Set functions
  • Geographic functions



Also see here for more functions and expressions you can use. 




Select functions


FunctionDescriptionExample
selected(string list, string value)Returns true if the given value was selected from the given multi-select list, otherwise returns false.
=selected($select_symptom, "cough") 
selected-at(string list, number index)Returns the value of the item at the 0-based index of the given list or returns an empty string if the item does not exist (including for negative index and index 0).
=selected-at($select_symptom, 1) returns the second selected item in the list 
count-selected(list)Returns the number of items selected in the given list.
=count-selected($select_symptom) 

 



Repeat functions


FunctionDescriptionExample
repeat-index()Returns the iteration index of the current repeating group.See example below
indexed-repeat()Indexed-repeat is a function that allows you to get information from a specific iteration of a repeat group and use in another area of the form.
=indexed-repeat($field, $group, repeat-index())
See example here

 



Tip: if your calculation does not seem to work correctly, try adding white space around the operator, e.g. instead of "=($field_1+5)" use "=($field_1 + 5)" 



Example

After entering the number of household members that live in a household, a repeating group is used to capture the details of each member. The fieldworker needs to keep track of which household member they are currently capturing information for. 

  • In the display text type '=', then select repeat-index()



  • Once the household member's name is captured you can refer to the person by name to capture their other details.  



  • On the device it will display as follows for the second member:






Set functions


FunctionDescriptionExample
count(list)Returns the number of objects in the argument set=count($repeat_group)
Returns the number of repeats in a group
count-non-empty(list)Returns the number of non-empty objects in the argument set.
position(.. )Returns the current iteration within a repeating group, similar to the =repeat-index() function.See example above

 


Example

The fieldworker must make sure that they have enumerated all members of a household. Display how many members they have captured by counting the number of times they have repeated the member details group.

  • The total number of household members has been captured in the $HH_Number field.
  • $Member_name is a required field in the member details group.
  • In the display text type '=', then select count(), then enter $Member_name as the argument.



  • After editing, the function and field references will be highlighted as follows:




Geographic functions


FunctionDescriptionExample
area(location_fields)Returns the calculated area in m2 of a set of geopoints. 

Note: It takes into account the circumference of the Earth around the equator but does not take altitude into account.
=area($location1 | $location2 | $location3)
distance(location_fields)Returns the distance in meters, of geopoints, in the sequence provided by the points in the parameter. 

Note: It takes into account the circumference of the Earth around the equator and does not take altitude into account.
=distance($location1 | $location2)