Merge different fields data in one field using Calculate

form-design
#1

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.

Regards,

#2

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.

#3

Thanks.

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

Regards,

#4

example.xls (97.5 KB)
Try this one

#5

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.

#7

Any Replay sir?
I shared the issue screenshot.

#8

I have sent you a excel file have you used this

#9

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.

#10

i am using ona.io and it wors on that

#11


See the result

#12

Fine...
but i facing issue.

#13

send me your form that u are using

#14

servant_no.xml (2.0 KB)

#15

example.xml (234.6 KB)
Try this one

#16

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

#17

ok u are using odk build fine tell me try

#18

Yes..
Thanks Sir.
I am waiting of your replay.

Regards

#19

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)

#20

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

Please help me.

#21

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