Dear community,
I have two attributes:
1) gebnr (this is the number of the studied field, le.g. 1 or 135...)
2) ID (this is the number of the studied field filled up to four digits, e.g. 1 -> 0001 or 135 -> 0135...)
I'd like to automatize the filling of the ID-attribute. I've tried to code a attribute rule, that says if
- gebnr < 10 then ID=000gebnr
- gebnr >=10 and gebnr<100 then ID=00gebnr
- gebnr>=100 and gebnr<1000 then ID=0gebnr
- gebnr>=1000 then ID=gebnr
My coding for ID looks like this now but it doesn't work (I have no experience in arcade at all):
var gebnr = $feature.GEBNRA
var ranking = When(gebnr < 10, Concatenate(000,gebnr), gebnr >=10 && gebnr < 100, Concatenate(00,gebnr), gebnr >= 100 && gebnr < 1000, Concatenate(0,gebnr), gebnr >= 1000, gebnr,-1);
Any ideas?
(Please, don't ask why these redundant attributes are necessary, it's German bureaucracy 😄 )
Solved! Go to Solution.
You can use the Text function for this:
return Text($feature.GEBNRA, '0000');
Could you please give a little more information about what you mean by "doesn't work"? Do you receive an error message? Are the returned values incorrect?
doesn't work means, that if I create for instance a new polygon and enter the gebnr = 1, the ID attribute stays at <NULL>
Can you show a screenshot of your attribute rule?
What is the datatype for the ID field?
You can use the Text function for this:
return Text($feature.GEBNRA, '0000');
@ChrisFox answer is the simplest solution to your problem. I would suggest for you to also research the 'console' function which will enable you to see the result in the messages.
Thank you all for your help! @ChrisFox answer solved the problem 🙂