- Select functions
- Repeat functions
- Set functions
- Geographic functions
Also see here for more functions and expressions you can use.
|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-index()||Returns the iteration index of the currently repeating group.||See below|
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)"
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:
|count(list)||Returns the number of objects in the argument set.||=count($repeat_group)|
|count-non-empty(list)||Returns the number of non-empty objects in the argument set.|
|position(field?)||If an argument is provided the function returns the position of that argument among its siblings (with the same name).|
|instance(string id)||This function allows access to instance data, within the same XForms Model, but outside the instance data containing the context node.|
|current()||Used inside predicates of expressions that use instance() to enable referring to a node relative to the context of the current question.|
|randomize(set, number seed)||Shuffles the given argument set using the “inside-out” variant of the Fisher-Yates algorithm. The optional seed argument performs a (reproducible) shuffle using the same algorithm with a seeded Park Miller Pseudo Number Generator.|
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:
|area(node-set ns|geoshape gs)||Returns the calculated area in m2 of either a node-set of geopoints or a geoshape value (not a combination of both) on Earth. It takes into account the circumference of the Earth around the equator but does not take altitude into account.|
|distance(node-set ns|geoshape gs|geotrace gt)||Returns the distance in meters of either a node-set of geopoints or a single geoshape value or a single geotrace value (not a combination of these) on Earth, in the sequence provided by the points in the parameter. It takes into account the circumference of the Earth around the equator and does not take altitude into account.|