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.
| Fungsi | Fungsinya | Example | Compared with ODK |
|---|---|---|---|
if() | if(kondisi, maka, jika tidak). Kondisi dapat menggabungkan perbandingan dengan and dan or. | if(${age} >= 18, 'adult', 'child') | Same |
concat() | Menggabungkan argumennya sebagai teks. | 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() | Dengan sebuah pertanyaan dan sebuah nilai: label opsi tersebut dalam daftar pertanyaan. Pertanyaan disebut namanya, tidak pernah dibaca sebagai jawaban. | 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() | Jumlah opsi dalam jawaban pilihan ganda; 0 jika tidak ada. | 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() | Salah. | 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() | Posisi entri pengulangan saat ini, dihitung dari 1; kosong di luar pengulangan. | 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() | Mengubah benar menjadi salah dan salah menjadi benar. | 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, kolom, kolom kunci, kunci): nilai dari set data yang dilampirkan pada formulir, dari baris yang kolom kuncinya sama dengan kunci. Tiga argumen pertama ditulis dalam tanda kutip; jika baris tidak ditemukan atau kunci kosong, hasilnya kosong. | 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(teks, pola): benar jika pola ditemukan dalam teks. Pola ditulis dalam tanda kutip. | 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(pertanyaan, nilai): benar jika opsi tersebut termasuk dalam jawaban. Centang dihitung 1 dalam aritmetika. | selected(${crops}, 'rice') | Same |
selected-at() | Dengan sebuah pertanyaan dan sebuah posisi: opsi pada posisi tersebut dalam jawaban pilihan ganda, dihitung dari 0. Dengan index(), fungsi ini menguji entri pengulangan saat ini. | 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() | Jumlah karakter dalam teks. | 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() | Hari jawaban diberikan, menurut zona waktu ruang kerja. Lihat Tanggal di bawah. | 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() | Benar. | 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() | Pada pengulangan: jumlah entri yang memiliki jawaban. Sebutkan pengulangan itu sendiri atau pertanyaan apa pun di dalamnya. | count(${member}) | Same |
sum() | Pada pengulangan: total dari suatu pertanyaan di dalamnya. | sum(${income}) | Same |
min() | Pada pengulangan: nilai terkecil dari suatu pertanyaan di dalamnya. | min(${age}) | Same |
max() | Pada pengulangan: nilai terbesar dari suatu pertanyaan di dalamnya. | max(${age}) | Same |
avg() | Pada pengulangan: rata-rata dari suatu pertanyaan di dalamnya. | 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}]/label | Same |
XLSForm features
| Feature | Compared with ODK | What to know |
|---|---|---|
default | Same | A default may be an expression, such as today() or ${other}, worked out when the question is first shown, as in ODK. |
read_only | Same | read_only may be yes or an expression; the answer cannot be changed while it holds. |
begin_repeat + relevant | Same | A relevant on a begin_repeat row hides the whole repeat while it does not hold. |
choice_filter | Same | choice_filter may be any expression: two parent questions, !=, selected() and the other functions. |
parameters: randomize=true seed=${q} | Same | In the parameters column, randomize=true shuffles a question's choices, and seed=${q} makes the order repeatable. |
trigger | Same | trigger 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}]/column | Same | instance('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_file | Different | select_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() | Different | The search() appearance is not read. Use a platform list with cl::source, or a dataset read with pulldata(). |
save_to, entities | Different | Entities (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::boundcl::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>
Repeat di dalam repeat digabungkan ke repeat yang melingkupinya, dan hal ini dinyatakan saat impor.
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:
| Kunci | Saat impor | Arti |
|---|---|---|
title_en | Diterapkan | Judul formulir dalam bahasa Inggris. Judul ini menggantikan judul formulir pada lembar settings. |
title_ar | Diterapkan | Judul formulir dalam bahasa Arab. |
title::<language> | Diterapkan | Judul formulir dalam bahasa lain yang dikenal platform, dengan nama bahasa seperti pada kolom label. |
form_type | Diterapkan | Jenis formulir: salah satu jenis formulir yang tercantum di bawah. |
scoring | Diterapkan | Cara penilaian formulir: metode penilaian atau kata penilaian. Lihat Penilaian. Juga dibaca sebagai scoring_method. |
pass_threshold | Diterapkan | Nilai kelulusan, dalam persentase. |
subject | Diterapkan | Register yang menjadi subjek formulir: salah satu kelompok responden yang tercantum di bawah. Juga dibaca sebagai respondent_type. |
public | Diterapkan | yes atau no: apakah formulir dapat diisi melalui tautan publik. |
scale_max | Diperiksa, tidak pernah disimpan | Skor maksimum yang dapat dicapai seluruh formulir. Lihat Penskoran. |
scored_question_count | Diperiksa, tidak pernah disimpan | Jumlah pertanyaan yang Anda tandai sebagai berskor. Impor melaporkan jumlah yang berbeda. |
cl_version | Dibaca | Versi tambahan ini yang menjadi dasar penulisan workbook, sehingga workbook lama dibaca sesuai maksudnya. Workbook tanpa keterangan ini dibaca sebagai versi 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_typesubject
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.