Hi guys,
I need to format a field to 4 digits in this way:
the user would input a number and
if 1 ----> the resulting number is 0001
if 12 ----> the resulting number is 0012
Is it possible to format this?
the field type is an integer and I put a length limit to 4.
thanks!
Solved! Go to Solution.
This would do the job, assuming that your integer question has nu for name.
if(string-length(${nu})=1,concat("000",${nu}),if(string-length(${nu})=2,concat("00",${nu}),if(string-length(${nu})=3,concat("0",${nu}),${nu})))
For example:
type | name | label | calculation | bind::esri:fieldType |
---|---|---|---|---|
integer | nu | A number | null | |
calculate | nu_trail | A number (trailing 0) | if(string-length(${nu})=1,concat("000",${nu}),if(string-length(${nu})=2,concat("00",${nu}),if(string-length(${nu})=3,concat("0",${nu}),${nu}))) | esriFieldTypeString |
This would do the job, assuming that your integer question has nu for name.
if(string-length(${nu})=1,concat("000",${nu}),if(string-length(${nu})=2,concat("00",${nu}),if(string-length(${nu})=3,concat("0",${nu}),${nu})))
For example:
type | name | label | calculation | bind::esri:fieldType |
---|---|---|---|---|
integer | nu | A number | null | |
calculate | nu_trail | A number (trailing 0) | if(string-length(${nu})=1,concat("000",${nu}),if(string-length(${nu})=2,concat("00",${nu}),if(string-length(${nu})=3,concat("0",${nu}),${nu}))) | esriFieldTypeString |
Sorry for the late answer: it is exactly what I was looking for!