SurveyLoopr
Tips & Tricks
14 min read

Number to Words in XLSForm: Write Amounts as Text

Mehrab Ali
Mehrab AliPublished November 15, 2026

To write a number in words in XLSForm, pick the word from a quoted list with selected-at('zero one two three', ${count}) in a calculate row. There is no built-in number-to-words function in ODK, KoboToolbox or SurveyCTO, so larger amounts are split into digits with div and mod and the words are joined with concat(). Each example below compiles with pyxform and ODK Validate, the check ODK Central runs when you upload a form.

Download example form (.xlsx)All five examples in one XLSForm, one group each. Tested with pyxform and ODK Validate; free to reuse under CC BY 4.0.Download

How do I turn a number into a word in XLSForm?

selected-at(list, position) returns one item from a space-separated list. Positions start at 0, so a list that starts with zero lines up with the number itself:

typenamelabelrequiredconstraintconstraint_messagecalculation
integerchildrenHow many children under 5 live in the household?yes. >= 0 and . <= 10Enter 0 to 10.
calculatechildren_wordsif(${children} = '', '', selected-at('zero one two three four five six seven eight nine ten', ${children}))
noteconfirm_childrenYou recorded ${children_words} children under 5. Confirm with the respondent.
surveychoicessettings

Two details matter:

  • The constraint protects the list. A position past the end of the list returns an empty text, not an error. Keep the constraint's upper limit equal to the last word in the list.
  • The outer if() handles the unanswered question. It keeps the note blank until the question is answered.
Warning:

Every word in the list must be a single token. 'twenty one' is two items, so every word after it moves one position and the form shows the wrong number without any error. Join compound words with a hyphen (twenty-one) or build them with concat(), as the next example does.

How do I write numbers up to 99 in words?

Listing 100 words works, but it is easy to miscount. Split the number into a tens digit and a ones digit instead. div is XLSForm's division and mod gives the remainder:

typenamelabelrequiredconstraintconstraint_messagecalculation
integervouchersHow many food vouchers did you hand over?yes. >= 0 and . <= 99Enter 0 to 99.
calculatev_tensint(coalesce(${vouchers}, 0) div 10)
calculatev_onescoalesce(${vouchers}, 0) mod 10
calculatevouchers_wordsif(${vouchers} = '', '', if(${vouchers} < 20, selected-at('zero one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen', ${vouchers}), concat(selected-at('zero ten twenty thirty forty fifty sixty seventy eighty ninety', ${v_tens}), if(${v_ones} > 0, concat('-', selected-at('zero one two three four five six seven eight nine', ${v_ones})), ''))))
noteconfirm_vouchersRead back to the respondent: ${vouchers_words} vouchers.
surveychoicessettings

The logic in plain words:

  1. Below 20, English has one word per number, so the form reads it straight from the first list.
  2. From 20 up, it takes the tens word (twenty, thirty) from the second list.
  3. If the ones digit is not 0, it adds a hyphen and the ones word: 47 becomes forty-seven, 40 stays forty.

The nested if() calls follow the rules in the XLSForm if statement guide: the first true condition wins. coalesce(${vouchers}, 0) turns an unanswered question into 0, so the helper rows always hold a number. The XLSForm calculations guide explains coalesce(), div and mod in more detail.

How do I write a cash amount in words, up to 999,999?

A long number is read in groups of three digits: 12,050 is "twelve" thousand and "fifty". So split the amount into a thousands part and a rest, convert each part with the same three rows, and join them. This form reads back a cash transfer in Bangladeshi taka:

typenamelabelrequiredconstraintconstraint_messagecalculation
integeramountHow much cash did the household receive (BDT)?yes. >= 0 and . <= 999999Enter 0 to 999999.
calculatethint(coalesce(${amount}, 0) div 1000)
calculatelocoalesce(${amount}, 0) mod 1000
calculateth_hint(${th} div 100)
calculateth_r${th} mod 100
calculateth_r_wordsif(${th_r} < 20, selected-at('zero one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen', ${th_r}), concat(selected-at('zero ten twenty thirty forty fifty sixty seventy eighty ninety', int(${th_r} div 10)), if(${th_r} mod 10 > 0, concat('-', selected-at('zero one two three four five six seven eight nine', ${th_r} mod 10)), '')))
calculateth_wordsconcat(if(${th_h} > 0, concat(selected-at('zero one two three four five six seven eight nine', ${th_h}), ' hundred '), ''), if(${th_r} > 0, ${th_r_words}, ''))
calculatelo_hint(${lo} div 100)
calculatelo_r${lo} mod 100
calculatelo_r_wordsif(${lo_r} < 20, selected-at('zero one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen', ${lo_r}), concat(selected-at('zero ten twenty thirty forty fifty sixty seventy eighty ninety', int(${lo_r} div 10)), if(${lo_r} mod 10 > 0, concat('-', selected-at('zero one two three four five six seven eight nine', ${lo_r} mod 10)), '')))
calculatelo_wordsconcat(if(${lo_h} > 0, concat(selected-at('zero one two three four five six seven eight nine', ${lo_h}), ' hundred '), ''), if(${lo_r} > 0, ${lo_r_words}, ''))
calculateamount_wordsif(${amount} = '', '', if(${amount} = 0, 'zero', normalize-space(concat(if(${th} > 0, concat(${th_words}, ' thousand '), ''), ${lo_words}))))
noteconfirm_amountRead back to the respondent: ${amount_words} taka.
surveychoicessettings

How the rows fit together:

RowFor 12,050For 999,999
th (thousands part)12999
lo (the rest)50999
th_wordstwelvenine hundred ninety-nine
lo_wordsfiftynine hundred ninety-nine
amount_wordstwelve thousand fiftynine hundred ninety-nine thousand nine hundred ninety-nine

normalize-space() removes the spare spaces that the joins leave behind, for example after hundred in 100,000. For British-style wording ("one hundred and fourteen"), replace ' hundred ' with if(${lo_r} > 0, ' hundred and ', ' hundred ') in lo_words, and the same with th_r in th_words.

To go into the millions, add a third part with int(${amount} div 1000000), three more helper rows, and the word million. The pattern is the same; only the row count grows.

How do I write dollars and cents in words?

Split the decimal into a whole part with int() and a cents part with round(... * 100, 0) mod 100. Rounding before mod matters: 0.29 times 100 is stored as 28.999..., and without round() the form would say twenty-eight cents. This example covers a clinic fee up to 999.99:

typenamelabelrequiredconstraintconstraint_messagecalculation
decimalfeeHow much did the clinic charge for the visit (USD)?yes. >= 0 and . <= 999.99 and regex(., '^[0-9]+(\.[0-9]{1,2})?$')Enter 0 to 999.99 with at most two decimals.
calculatefee_dollarsint(coalesce(${fee}, 0))
calculatefee_centsround(coalesce(${fee}, 0) * 100, 0) mod 100
calculatefee_hint(${fee_dollars} div 100)
calculatefee_r${fee_dollars} mod 100
calculatefee_r_wordsif(${fee_r} < 20, selected-at('zero one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen', ${fee_r}), concat(selected-at('zero ten twenty thirty forty fifty sixty seventy eighty ninety', int(${fee_r} div 10)), if(${fee_r} mod 10 > 0, concat('-', selected-at('zero one two three four five six seven eight nine', ${fee_r} mod 10)), '')))
calculatefee_dollar_wordsif(${fee_dollars} = 0, 'zero', normalize-space(concat(if(${fee_h} > 0, concat(selected-at('zero one two three four five six seven eight nine', ${fee_h}), ' hundred '), ''), if(${fee_r} > 0, ${fee_r_words}, ''))))
calculatefee_cent_wordsif(${fee_cents} < 20, selected-at('zero one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen', ${fee_cents}), concat(selected-at('zero ten twenty thirty forty fifty sixty seventy eighty ninety', int(${fee_cents} div 10)), if(${fee_cents} mod 10 > 0, concat('-', selected-at('zero one two three four five six seven eight nine', ${fee_cents} mod 10)), '')))
calculatefee_wordsif(${fee} = '', '', concat(${fee_dollar_words}, if(${fee_dollars} = 1, ' dollar', ' dollars'), ' and ', ${fee_cent_words}, if(${fee_cents} = 1, ' cent', ' cents')))
noteconfirm_feeAmount in words: ${fee_words}.
surveychoicessettings

An answer of 114.75 shows "one hundred fourteen dollars and seventy-five cents". The two-decimal regex() in the constraint is required, not decoration: with 114.999 the cents would round up to 100 and drop to zero. The pattern is explained in limit digits and decimal places.

How do I write numbers in words in another language?

The split-and-join method fits languages that build numbers from regular parts, as English does; translate the lists and the joining words. It does not fit Bangla, Hindi or Urdu, where every number up to 99 has its own word. For those, look the word up in a CSV attached to the form with pulldata():

typenamelabelrequiredconstraintconstraint_messagecalculation
integerkitsHow many hygiene kits did the household receive?yes. >= 0 and . <= 999Enter 0 to 999.
calculatekits_words_bnif(${kits} = '', '', pulldata('number_words', 'words_bn', 'number_key', ${kits}))
noteconfirm_kitsRead back in Bangla: ${kits_words_bn}
surveychoicessettings

The attached file number_words.csv has one row per number, built once in Excel:

number_key,words_en,words_bn
0,zero,শূন্য
1,one,এক
2,two,দুই
21,twenty-one,একুশ

A 1,000-row file covers 0 to 999. For larger amounts, keep the th and lo split from the cash example and look up each part, so the same small file serves amounts up to 999,999. Attaching the file and the lookup rules are covered in pulldata() in XLSForm.

Common number-to-words mistakes and how to fix them

The error text below is what ODK Validate returns, which is what ODK Central, KoboToolbox and the XLSForm converter show when they reject a form:

You wroteWrite insteadError you will see
SpellNumber(${n})selected-at('zero one two', ${n})cannot handle function 'SpellNumber'
choose(${n}, 'one', 'two')selected-at('zero one two', ${n})cannot handle function 'choose'
selected-at('zero one two')selected-at('zero one two', ${n})cannot handle function 'selected-at'. Requires 2 arguments but 1 provided.
selected-at(zero one two, ${n})Put the list in quotesCouldn't understand the expression starting at this point
${n} / 10${n} div 10Unexpected beginning of path in expression
${n} % 10${n} mod 10Couldn't understand the expression starting at this point
floor(${n} div 10)int(${n} div 10)cannot handle function 'floor'
selected-at(...) & ' taka'concat(selected-at(...), ' taka')Couldn't understand the expression starting at this point
A list that starts with oneStart the list with zeroNo error, but every word is one too high
'twenty one' inside the listtwenty-oneNo error, but later words are shifted

The last two rows compile and are wrong for every respondent, so test the edges by hand: 0, 10, 19, 20, 21, 99, 100, 101, 1,000 and the largest allowed amount. For other messages, see common XLSForm errors, or paste the form into the free XLSForm validator.

Does this work the same in ODK, KoboToolbox and SurveyCTO?

The functions used here (selected-at(), concat(), int(), round(), coalesce(), div, mod) are part of the ODK XForms specification, so ODK Collect, KoboCollect and Enketo web forms read these forms unchanged. What differs is where you type the expressions:

PlatformWhere the expressions go
ODK (XLSForm)calculation column of calculate rows
KoboToolbox FormbuilderOne Calculate question per row; type the expression in its calculation box
KoboToolbox (XLSForm upload)Same as ODK
SurveyCTOcalculation column of calculate fields

SurveyCTO documents selected-at() for select_multiple fields. Before fieldwork, test the quoted-list form of it in SurveyCTO's form preview; if it does not return the word, use the pulldata() lookup above, which SurveyCTO supports with an attached CSV. On any platform, the words are saved in the submission as text, in their own column next to the number.

Why show the amount in words at all?

A typed amount is the easiest answer to get wrong: 5000 and 50000 look alike on a small screen. A note that says "fifty thousand taka" makes an extra zero obvious while the respondent is still there, and reading it aloud gives the respondent the chance to object. For cash distributions and receipts, the words in the dataset also match what was written on the paper voucher.

Tip:

The helper rows are tedious to type and easy to get slightly wrong. In LooprAI, describe the result instead: "show the cash amount in words, up to 999,999 taka, and read it back in a note". LooprAI writes the rows and compiles the form with pyxform before anything is saved, so a wrong function name or a missing argument never reaches your form.

Build my first form free

Next: XLSForm calculation examples →

Frequently Asked Questions

How do I convert a number to words in XLSForm?

Add a calculate row with selected-at('zero one two three four five', ${count}). It returns the word at that position in the space-separated list, counted from 0. For larger numbers, split the value with div and mod and join the words with concat().

Is there a built-in number to words function in ODK or KoboToolbox?

No. ODK, KoboToolbox and SurveyCTO have no function like Excel's SpellNumber. Using one fails with the error cannot handle function. You build the words from lists with selected-at(), or look them up in an attached CSV file with pulldata().

Why does selected-at() return the wrong word?

Positions start at 0, so the list must begin with zero for the position to equal the number. A word containing a space, such as twenty one, counts as two items and shifts everything after it. Neither mistake produces an error, so test several numbers.

How do I write an amount with cents in words in XLSForm?

Take the whole part with int(${fee}) and the cents with round(${fee} * 100, 0) mod 100, convert each to words, and join them with concat(). Limit the question to two decimal places with a regex() constraint so the cents never round up to 100.

How large a number can I convert to words in XLSForm?

As large as you add rows for. Each group of three digits needs about four calculate rows: the example on this page covers 0 to 999,999 with eleven rows. Adding millions takes one more group and the word million. Always cap the question with a constraint.

Can I show number words in Bangla, Hindi or another language?

Yes. For languages with regular number words, replace the English lists. For Bangla, Hindi or Urdu, where numbers up to 99 each have their own word, attach a CSV with one row per number and read the word with pulldata().

No Credit Card Required

Build the form first. Add hosting when you need it.

Start free with LooprAI, then deploy a managed ODK Central server or run DataSnap checks when your project is ready.

Automation handles the mechanical work.

Researchers decide what the evidence means.