Merge different fields data in one field using Calculate

Dear ODK Team,

I have four fields (all text type) (i.e Phase,Sector,house no and person identity card number)

I wanted to calculate automatically (merge four question) in servant no text filed.


Could you perhaps give a specific example of what you wish to accomplish. It's not clear if (a) you have 4 form questions (ie 'fields') - Phase, Sector, House#, ID - that you then wish to 'merge' into a single result [in which case you can use concat() to do so], or (b) you have 4 values combined somehow (eg in a CSV string, space separated string, etc) that you wish to extract into 4 distinct fields/results.


I use concat() function,it's not concating values working.
I want concat values/data of 4 fields in my servant filed.


example.xls (97.5 KB)
Try this one

Please see i am facing this issue.

In servant_no you can see it's showing field name not values/data.
It should be Q-A-F-23 in Servant_no field.

Any Replay sir?
I shared the issue screenshot.

I have sent you a excel file have you used this

facing issue below:

In servant_no you can see it's showing field name not values/data.
It should be Q-A-F-23 in Servant_no field.

i am using and it wors on that

See the result

but i facing issue.

send me your form that u are using

servant_no.xml (2.0 KB)

example.xml (234.6 KB)
Try this one

Not successful sir.
Please see the below screenshot of form uisng ODK Build.

ok u are using odk build fine tell me try

Thanks Sir.
I am waiting of your replay.


Hi @tasadduq786, you were very close with your form calculation, however you do not need to include the "calculate = ..." when you enter a calculation in ODK Build; just enter the actual calculation itself. That is, in the Advanced -> Calculate box for your servant_no, just enter:

concat(${Q1}, '-', ${Q2}, '-', ${Q3}, '-', ${Q4})

I've taken the liberty of rewriting your form in ODK Build:

mergefields.odkbuild.json (1.5 KB)

which you can load into ODK Build via "Load Form from File..." [please rename the file to remove the '.json' suffix, which I had to add to get the ODK Forum to permit me to attach it...]. Have a play around with the form in ODK Build.

And here is the resulting ODK Build exported XLSForm, which you can load into XLSForm Online to see it running under Enketo:

mergefields-export.xlsx (16.9 KB)

I implemented your provided file in ODK build.
It's giving me above mention error.

Please help me.

Sorry, my error - I thought ODK Build natively handles the XLSForm ${foo} variable reference syntax. It doesn't. Therefore these strings are passed unchanged to the resulting XML, rather than being resolved to their actual instance XML elements. Whereas in XLSForm

${phase} --> /data/phase

So in ODK Build, you have to specify the explicit full path to the referenced value, usually starting at "/data/...", and also including any subgroups the question may lie under (note, in our form there are none). Try this Build form instead:

mergefields.odkbuild.json (1.5 KB)

mergefields.xml (2.1 KB)

1 Like