Creating a text number as it is done in excel when using text function (having zero in front of a number)

I want to create a number as text function in excel, it does:
For example if I have ID=1,2,…10 etc and I want to create ID number=001, 002,…010 etc
ID number=text(${ID},“000”).
How can I generate this type of ID in kobo or ODK during data collection/on the field?
Please support me

@DJAA, you could do it as outlined in the post discussed previously:

great, but I have one issue: this works only when you have a number less than or equal to 9. I have tried a large number and it doesn’t work as I want.
for example, for 001 its ok but when it comes to two digits, it does it like this 0056 instead of providing this 056. Any hint ?

@DJAA, if this is your requirement, maybe try using this workaround shared previously. It should solve your issue:

I this this one works when you enter them your self, for my case I want to concatinate the incremental generated ID by last-saved feature to create something like 001 002 …056,…120 etc. I have tried this formula at it works for number less than 100 but I failed to make it working correctly . if(${num} <=9, concat(‘00’, ${num}), concat('0’, ${num})) this works but failed for 3 digits, it does these 001, …056,… but it fails when it is displaying 100 it displayed like this 0100. If you can just correct this formula it can be very supportive for me. I have tried these but it fails if((${num} <=9, concat(‘00’, ${num}), if(${num} <=99, concat('0’, ${num})), ${num}) if you can find a way to arrange it it can be very supportive.

@DJAA, in this case, you will need to use the nested if as outlined in the image shared below (please however note that this workaround is meant to handle up to 3 digit number):

In the survey tab of your xlsform:

Data entry screen as seen in Enketo: when entering a one-digit number

Data entry screen as seen in Enketo: when entering a two-digit number

Data entry screen as seen in Enketo: when entering a three-digit number

Data entry screen as seen in Enketo: when entering a four digit number

Reference xlsform:

If-Statement.xlsx (10.7 KB)

Great!

It works very well, I appreciate your support

Thank you!

1 Like