İçeriğe geç
Özellikler Fiyatlandırma Belgeler İletişim Oturum aç Başlayın
Dil

Porting from ODK, KoboToolbox and SurveyCTO

What a form written for another XLSForm tool does here: every function and feature, marked the same, better, or different with what to write instead.

A workbook written for ODK, KoboToolbox or SurveyCTO imports here as it is. KoboToolbox fills forms with ODK Collect and Enketo, so its functions are ODK's. This page compares each function and feature with ODK, the reference most workbooks follow, and names where SurveyCTO or CommCare spellings are read too.

The function table is generated from the platform's expression evaluator, so it lists exactly the functions evaluated today. When this page disagrees with what the form check or the import report says about your form, trust the screen: it reads your form, while this page describes the platform.

How to read this page

  • Same: Written and evaluated exactly as in ODK.
  • Better: Does what ODK does and more, or offers something ODK lacks. The reason is given beside it.
  • Different: ODK's spelling is not read here. Write what the table says instead.

Functions

Every function works alike in relevant, constraint and calculation: there is one list for all of them.

A few functions can only be worked out where the form is filled: a random draw, a new identifier, the first value kept by once(), and the time spent filling. The phone or browser computes them, and the value it sends is the one kept.

FunctionWhat it doesExampleCompared with ODK
if()if(condition, then, otherwise). The condition may join comparisons with and and or.if(${age} >= 18, 'adult', 'child')Same
concat()Joins its arguments as text.concat(${first_name}, ' ', ${last_name})Same
abs()The absolute value of a number.abs(${difference})Same
acos()The angle, in radians, whose cosine is the number given.acos(0.5)Same
area()The area of a closed shape, in square metres. An unanswered shape has an area of 0, as in ODK.area(${field_shape})Same
asin()The angle, in radians, whose sine is the number given.asin(0.5)Same
atan()The angle, in radians, whose tangent is the number given.atan(1)Same
atan2()atan2(y, x): the angle, in radians, between the positive x axis and the point (x, y).atan2(${y}, ${x})Same
base64-decode()Turns a text written in base64 back into ordinary text.base64-decode(${encoded})Same
boolean()True for a number other than 0 and for text that is not empty; false otherwise.boolean(${count})Same
boolean-from-string()True only for the text true or 1; any other text is false.boolean-from-string(${flag})Same
ceiling()The smallest whole number that is not less than x: ceiling(2.1) is 3.ceiling(${households} div 10)Better. Not in ODK, where you write round() or int() instead.
checklist()checklist(min, max, condition, …): true when the number of conditions that hold lies between min and max. A bound of minus one means no bound.checklist(1, 2, ${a}, ${b}, ${c})Same
choice-label()Given a question and a value: the label of that option in the question’s list. The question is named, never read as an answer. With the question alone, it is the label of what the question holds (its first option, for a multiple choice answer).choice-label(${crop}, ${crop})Better. From SurveyCTO. ODK needs a lookup into the choice list for the same label.
coalesce()coalesce(a, b): a when it is not blank, otherwise b. It reads a blank as 0 when b is 0.coalesce(${income}, 0)Same
cond()cond(c1, v1, c2, v2, …, otherwise): the value after the first condition that holds; when none holds, the last value.cond(${age} < 5, 'infant', ${age} < 18, 'child', 'adult')Better. From CommCare: one call instead of if() inside if().
contains()contains(text, part): true when the part appears in the text.contains(${name}, 'Ali')Same
cos()The cosine of an angle in radians.cos(${angle})Same
count-if()Given a question inside a repeat and a condition: how many entries meet the condition.count-if(${sex}, ${sex} = 'female')Better. SurveyCTO's spelling. ODK writes the condition in square brackets, as in count(${r}[condition]), and that works here too.
count-items()Given a separator and a list held in text: how many items it holds. With a space as the separator it reads a multiple choice answer.count-items(' ', ${crops})Better. From SurveyCTO: a list held in text, such as a multiple choice answer, which ODK can only test with selected().
count-selected()How many options a multiple choice answer holds; 0 when it holds none.count-selected(${crops})Same
date()A date, from a number of days since 1 January 1970 or from text written as year, month and day.date('2026-01-31')Same
date-time()Like date, for a date with a time of day.date-time(decimal-date-time(now()))Same
de-duplicate()Given a separator and a list held in text: the list with repeated items left out, in the order they first appear.de-duplicate(' ', ${all_crops})Better. From SurveyCTO: a list held in text, such as a multiple choice answer, which ODK can only test with selected().
decimal-date-time()The number of days since 1 January 1970, with the time of day as a fraction.decimal-date-time(${visit_date})Same
decimal-time()The time of day as a fraction of a day, so noon is 0.5.decimal-time(${start_time})Same
digest()Given a text and an algorithm in quotes (MD5, or a SHA algorithm spelled as ODK spells it): the text's digest in base64 (ODK's default), or in hexadecimal when the third argument is 'hex'.digest(${phone}, 'SHA-256')Same
distance()The distance in metres along two or more locations, or along the points of a line or shape, computed as ODK computes it.distance(${route})Same
duration()The seconds the response has been open for filling, counted on the device that fills it.duration()Better. From SurveyCTO. ODK records only start and end times as metadata.
ends-with()Given a text and a part: true when the text ends with the part.ends-with(${email}, '.org')Same
enumerator-id()The data collector's ID, from their CommonLynk account.enumerator-id()Better. Read from the data collector's CommonLynk account. ODK records only the username set on the phone.
enumerator-name()The data collector's full name, from their CommonLynk account.enumerator-name()Better. Read from the data collector's CommonLynk account. ODK records only the username set on the phone.
exp()The natural exponential of a number: e raised to that power.exp(1)Same
exp10()10 raised to the power of a number.exp10(2)Same
extract-signed()Given a signed message and a public key, both in base64: the message when its signature is valid, otherwise blank.extract-signed(${message}, ${public_key})Same
false()False.false()Same
floor()The largest whole number that is not more than x: floor(2.9) is 2.floor(${age_years})Better. Not in ODK, where you write round() or int() instead.
format-date()Given a date and a format: the date written in that format, with %Y %y %m %n %b %d %e %a read as ODK reads them. Month and day names are in the form’s language, so an Arabic form gets Arabic names.format-date(${visit_date}, '%e %b %Y')Better. Month and day names follow the form's language, so an Arabic form shows Arabic names.
format-date-time()Like the function above, for a date with a time of day; it also reads %H %h %M %S and %3 (milliseconds).format-date-time(now(), '%Y-%m-%d %H:%M')Better. Month and day names follow the form's language, so an Arabic form shows Arabic names.
format-number()A number with thousands separators, rounded to the decimal places given as a second argument. On an Arabic form it is written in Arabic digits.format-number(${income}, 2)Better. From SurveyCTO. On an Arabic form the figure is written in Arabic digits.
geofence()geofence(location, shape): true when the location lies inside the shape.geofence(${point}, ${zone})Same
hash()Another name for digest(), as SurveyCTO spells it.hash(${phone}, 'SHA-256')Better. SurveyCTO's name for digest(); both work here.
index()The position of the current repeat entry, counting from 1; blank outside a repeat.index()Better. From SurveyCTO. ODK writes position(..), which works here too.
indexed-repeat()Given a question inside a repeat, the repeat, and an entry number counting from 1: that question’s answer in that entry, or a blank when there is no such entry.indexed-repeat(${member_name}, ${member}, 1)Same
int()The whole number part of a number: the decimals are dropped, toward zero for a negative number too.int(${age_years})Same
intersects()True when a trace or a shape crosses itself.intersects(${boundary})Same
item-at()Given a separator, a list held in text and a position counted from 0: the item at that position.item-at(' ', ${crops}, 0)Better. From SurveyCTO: a list held in text, such as a multiple choice answer, which ODK can only test with selected().
item-index()Given a separator, a list held in text and a value: the value's position counted from 0, or minus one when it is not in the list.item-index(' ', ${crops}, 'rice')Better. From SurveyCTO: a list held in text, such as a multiple choice answer, which ODK can only test with selected().
item-present()Given a separator, a list held in text and a value: true when the value is in the list.item-present(' ', ${crops}, 'rice')Better. From SurveyCTO: a list held in text, such as a multiple choice answer, which ODK can only test with selected().
join()join(separator, question): the answers to a question inside a repeat, in entry order, joined by the separator. A blank answer keeps its place, as in ODK, so two separators meet where it was; a condition in square brackets works here too. Over a multiple choice question that is not repeated it gives the chosen values separated by spaces, as ODK does.join(', ', ${member_name})Same
join-if()Given a separator, a question inside a repeat and a condition: the answers of the entries that meet the condition, joined by the separator.join-if(', ', ${member_name}, ${age} >= 18)Better. SurveyCTO's spelling. ODK writes the condition in square brackets, as in count(${r}[condition]), and that works here too.
jr:choice-name()ODK’s spelling of a choice label: given a value and a question named in quotes, the label of that value in the question’s list. It works anywhere in an expression, inside a repeat too; for a multiple choice answer it reads the first option chosen.jr:choice-name(${crop}, '${crop}')Same
linebreak()A line break, for concat() in a note or a label.concat(${name}, linebreak(), ${village})Better. From SurveyCTO. ODK cannot write a line break in a calculation.
log()The natural logarithm of a number.log(${value})Same
log10()The base 10 logarithm of a number.log10(${value})Same
lower()The text with its Latin capital letters made small.lower(${email})Better. Not in ODK; SurveyCTO and CommCare have it.
lower-case()Another name for lower(), as SurveyCTO and CommCare spell it.lower-case(${email})Better. Not in ODK; SurveyCTO and CommCare have it.
max-if()Given a question inside a repeat and a condition: the largest value of that question among the entries that meet the condition.max-if(${age}, ${sex} = 'female')Better. SurveyCTO's spelling. ODK writes the condition in square brackets, as in count(${r}[condition]), and that works here too.
min-if()Given a question inside a repeat and a condition: the smallest value of that question among the entries that meet the condition.min-if(${age}, ${sex} = 'female')Better. SurveyCTO's spelling. ODK writes the condition in square brackets, as in count(${r}[condition]), and that works here too.
normalize-space()The text with the spaces at both ends removed and every run of spaces reduced to one.normalize-space(${name})Same
not()Turns true into false and false into true.not(selected(${crops}, 'rice'))Same
now()The date and time of filling, with the workspace’s time zone offset. In a calculation it is fixed when the response is saved: at Submit online, and offline at the moment the collector pressed Submit on the device. Editing the response keeps the first value.now()Same
number()A value as a number. A date reads as the number of days since 1 January 1970; text that is not a number gives a blank.number(${typed_amount})Same
once()once(x): x as it was first worked out, kept from then on, so it does not change while the response is filled or edited.once(random())Same
pi()The number π, 3.14159…pi()Same
position()Inside a repeat, the number of the current entry counting from 1, like index(). Inside a condition in square brackets, the number of the entry being tested.position(..)Same
pow()pow(x, y): x raised to the power y.pow(${height}, 2)Same
pulldata()pulldata(file, column, key column, key): a value from a dataset attached to the form, from the row whose key column equals the key. The first three are written in quotes; no such row, or a blank key, gives a blank.pulldata('prices', 'price', 'item', ${item})Different. Attach the table to the form as a dataset instead of uploading a CSV media file. The formula is written the same way.
random()A random number from 0 up to, but not including, 1. Wrap it in once() to keep one number for each response.random()Same
randomize()Given a list of values separated by spaces: the same values in a random order. With a second argument, a seed, the order is the same every time for that seed.randomize(${crops}, 42)Different. ODK shuffles the items of a choice list; here it shuffles a list of values held in text and separated by spaces, such as a multiple choice answer. To shuffle a question's choices, use the parameters column.
regex()regex(text, pattern): true when the pattern is found in the text. The pattern is written in quotes.regex(${phone}, '^01[0-9]{9}$')Same
replace()replace(text, pattern, replacement): the text with every match of the regular expression replaced. $1 in the replacement is the first group.replace(${phone}, '[^0-9]', '')Better. From CommCare. ODK cannot replace text by a pattern.
round()round(x, n): x rounded to n decimal places exactly as ODK computes it, on the binary number: 2.5 gives 3, and 1.005 gives 1 to two places because 1.005 is stored as 1.00499..., the figure ODK writes too. Without n, to a whole number.round(${bmi}, 1)Same
selected()selected(question, value): true when that option is among the answers. A tick counts 1 in arithmetic.selected(${crops}, 'rice')Same
selected-at()Given a question and a position: the option at that position of a multiple choice answer, counting from 0. With index() it tests the current repeat entry.selected-at(${crops}, 0)Same
sin()The sine of an angle in radians.sin(${angle})Same
sort()Given a list of values separated by spaces: the values in order, or in reverse order when the second argument is false().sort(${crops})Better. From SurveyCTO: a list held in text, such as a multiple choice answer, which ODK can only test with selected().
sqrt()The square root of a number.sqrt(${area})Same
starts-with()Given a text and a part: true when the text begins with the part.starts-with(${national_id}, '2')Same
string()A value as text. A number is written without trailing zeros and never with an exponent.string(${age})Same
string-length()The number of characters in a text.string-length(${national_id})Same
substr()substr(text, start, end): the characters from start up to but not including end, counting from 0 as ODK does; without end, to the end of the text. Every letter and mark counts as a character, Arabic ones included.substr(${national_id}, 1, 3)Same
substring-after()Given a text and a part: the text after the first place the part appears, or empty text when it does not appear.substring-after(${email}, '@')Same
substring-before()Given a text and a part: the text before the first place the part appears, or empty text when it does not appear.substring-before(${email}, '@')Same
sum-if()Given a question inside a repeat and a condition: the total of that question over the entries that meet the condition.sum-if(${income}, ${sex} = 'female')Better. SurveyCTO's spelling. ODK writes the condition in square brackets, as in count(${r}[condition]), and that works here too.
tan()The tangent of an angle in radians.tan(${angle})Same
today()The day the answer is given, in the workspace’s time zone. See Dates below.today()Same
translate()translate(text, from, to): each character of from in the text is replaced by the character at the same place in to, or removed when to is shorter.translate(${code}, 'abc', 'ABC')Same
true()True.true()Same
upper()The text with its Latin small letters made capital.upper(${code})Better. Not in ODK; SurveyCTO and CommCare have it.
upper-case()Another name for upper(), as SurveyCTO and CommCare spell it.upper-case(${code})Better. Not in ODK; SurveyCTO and CommCare have it.
username()The username of the data collector's CommonLynk account; blank when nobody is signed in, as on a public link.username()Better. Read from the data collector's CommonLynk account. ODK records only the username set on the phone.
uuid()A new unique identifier of 36 characters. uuid(n) gives n random letters and digits instead.uuid()Same
version()The number of the form version the response is filled against.version()Better. From SurveyCTO. ODK keeps the version only in the settings sheet.
weighted-checklist()Like checklist, with a weight after each condition: true when the weights of the conditions that hold add up to a value between min and max. A bound of minus one means no bound.weighted-checklist(3, 5, ${a}, 2, ${b}, 3)Same
count()Over a repeat: how many entries hold an answer. Name the repeat itself or any question inside it. A condition in square brackets after the name counts only the entries where it holds, for example count(${member}[${age} > 17]).count(${member})Same
sum()Over a repeat: the total of a question inside it. An entry whose answer is blank is skipped, as ODK skips it. A condition in square brackets after the name keeps only the entries where it holds.sum(${income})Same
min()Over a repeat: the smallest value of a question inside it, among the entries where a condition in square brackets holds when one is written; a blank answer is skipped. Given two or more values instead, as in min(${a}, ${b}): the smallest of them, a blank one skipped, or a blank when one is not a number.min(${age})Same
max()Over a repeat: the largest value of a question inside it, among the entries where a condition in square brackets holds when one is written; a blank answer is skipped. Given two or more values instead, as in max(${a}, ${b}): the largest of them, a blank one skipped, or a blank when one is not a number.max(${age})Same
avg()Over a repeat: the average of a question inside it. A condition in square brackets after the name keeps only the entries where it holds.avg(${age})Better. ODK has no average function; there you write sum() div count(). Both work here.
count-non-empty()Over a repeat: how many entries hold an answer to the question named. A condition in square brackets works here too.count-non-empty(${phone})Same
instance()instance('list')/root/item[name = ${q}]/label reads a column of a choice list (name, label or any other column of the choices sheet) for the first item the condition in brackets holds for; count(instance('list')/root/item[...]) counts them. The list is named as in the workbook.instance('crops')/root/item[name = ${crop}]/labelSame

XLSForm features

FeatureCompared with ODKWhat to know
defaultSameA default may be an expression, such as today() or ${other}, worked out when the question is first shown, as in ODK.
read_onlySameread_only may be yes or an expression; the answer cannot be changed while it holds.
begin_repeat + relevantSameA relevant on a begin_repeat row hides the whole repeat while it does not hold.
choice_filterSamechoice_filter may be any expression: two parent questions, !=, selected() and the other functions.
parameters: randomize=true seed=${q}SameIn the parameters column, randomize=true shuffles a question's choices, and seed=${q} makes the order repeatable.
triggerSametrigger works out a calculation again when the question it names changes, and only then.
hint: ${q}Same${q} is filled in hints, guidance hints and constraint messages, as it is in labels.
instance('list')/root/item[name = ${q}]/columnSameinstance('list')/root/item[name = ${q}]/column reads a column of a choice list, such as a value kept beside each choice.
select_one_from_file, select_multiple_from_fileDifferentselect_one_from_file and select_multiple_from_file read their options from the choices sheet under the file's name without its extension, or from a dataset of that name attached to the form (columns name and label), when the form is updated from the workbook. Better still, draw the list from a platform list with cl::source, which follows the register and every language.
appearance: search()DifferentThe search() appearance is not read. Use a platform list with cl::source, or a dataset read with pulldata().
save_to, entitiesDifferentEntities (save_to and entity lists) are not read. People, households and places live in the workspace's registers, and a later form reads them through its respondent list and preloaded answers.

Notes and the question after them

A note is shown on the same card as a question, so the two read together. Which question it joins follows three rules:

  • A note travels with the next question in the same group or section, and only there.
  • A group that holds only notes is a screen of its own.
  • A note at the end of a group, with no question after it in that group, joins the group's previous question.

So a note never moves into another group. The XLSForm reference describes the two columns that set a note's place yourself:

  • cl::bound
  • cl::note_placement

Blanks in calculations

A blank operand makes the arithmetic it is part of blank, exactly as in ODK: when a question is unanswered or hidden, adding to it gives a blank. This is ODK's rule, kept on purpose so a ported form gives the same figures. Read a blank as 0 with coalesce():

  • coalesce(${a}, 0) + coalesce(${b}, 0)

Multiple choice answers in expressions

Expressions read a multiple choice answer as ODK does: the chosen values, separated by spaces. Text functions, join(), concat(), string() and comparisons all see that text. To test one choice, use selected(); to count or pick choices, use the list functions:

  • selected(${crops}, 'rice')
  • count-selected(${crops})
  • count-items(' ', ${crops})
  • item-at(' ', ${crops}, 0)

An export can also add, after each column, a column holding the chosen codes separated by spaces, as ODK writes them; the usual columns stay as they are.

Pages and repeats

A group with the field list appearance shows its questions on one screen, as in ODK.

  • begin_group · appearance: field-list

A repeat inside such a group is not supported, the same as in ODK. Put the repeat outside the group, and give the field list appearance to a group inside each entry instead.

To test a form as a collector sees it, open the designer's preview at the address below. It opens at the question named in start=, can fill every required answer with test values, and saves nothing. The fill page does not read start=.

  • /forms/<form id>/preview/?start=<variable>

A repeat inside a repeat is merged into the one around it, and the import says so.

The cl:: columns and the commonlynk sheet

Columns that start with cl:: and the commonlynk sheet carry what XLSForm has no column for: scoring, platform lists, a note's place, who a question is shown to, and the form's own settings. Other tools ignore them, so the same workbook still opens in ODK, KoboToolbox and SurveyCTO. The XLSForm reference describes each column:

  • /docs/forms-and-data-collection/xlsform-reference/#columns

The commonlynk sheet holds one setting and its value per row. These settings are applied or checked on import:

KeyOn importMeaning
title_enAppliedThe form title in English. It wins over the form title on the settings sheet.
title_arAppliedThe form title in Arabic.
title::<language>AppliedThe form title in any other language the platform knows, the language named as on a label column.
form_typeAppliedThe kind of form: one of the form types listed below.
scoringAppliedHow the form is scored: a scoring method or a scoring word. See Scoring. Also read as scoring_method.
pass_thresholdAppliedThe pass mark, as a percentage.
subjectAppliedThe register the form is about: one of the respondent groups listed below. Also read as respondent_type.
publicAppliedyes or no: whether the form may be filled through a public link.
scale_maxChecked, never storedThe most the whole form can score. See Scoring.
scored_question_countChecked, never storedHow many questions you marked as scored. The import reports a different count.
cl_versionReadThe version of these additions the workbook was written for, so an older workbook is read as it was meant. A workbook without it is read as version 1.

A setting left undecided blocks publishing. Set the form type and the respondent group in this sheet, so the form arrives ready for its check.

  • form_type
  • subject

Importing a form unchanged

Usually, yes. Upload the workbook as it is and choose which tool wrote it, so the import reads that tool's own spellings. The preview names every row it could not apply, and why, before anything is saved.

What the preview may ask you to change is in the rows marked Different above. Everything marked Same or Better imports and fills as written.