Hi everyone, i try to use arcade to label my data in ArcGIS online but I'm not manage to do it since I'm very bad in coding and new to arcade.
I have a water pipe data where in the attributes I have field of pipe material and pipe diameter( both are domain coded),
I want to label my data using both field and I want to abbreviate the text for example
Mild Steel to MS, Unknown to Unk ,Abestos Cement to AC and so on..
It should be label as per figure attached.
for ArcGIS Pro , i manage to use the abbreviation library but when published to online, it's not working. I try to use function replace but not work.. What should i do..
Thank You in advance
Solved! Go to Solution.
When is a good function for this, as @JohnEvans6 demonstrates well. I'd also like to suggest using Decode, for when you're simply rewriting the contents of an entire field. You point the function at the field you're using, then supply a series of matching values, then a fallback at the end.
return Decode(
$feature.Pipematerial,
'Mid Steel', 'MS',
'Unknown', 'UNK',
'Asbestos Cement', 'AC',
$feature.Pipematerial
)
If no match is found, it will return the unabbreviated value at the end.
Dear Nadia,
I hope you are doing great when reading this message,
Could you please share more info on your attribute table and fields and values.
Thank you and best of luck
Would something like this work for your arcade pop up expression?
var pipe_mtrl = $feature.Pipematerial // Replace with your pipe material field name
var pipe_diam = $feature.Pipediameter // Replace with diameter field
// Add below asbestos cement for more materials. Not provided is your catch all; change to whatever default return is needed
var pipe_abbrv = When(
pipe_mtrl == 'Mid Steel', 'MS',
pipe_mtrl == 'Unknown', 'UNK',
pipe_mtrl == 'Asbestos Cement', 'AC',
'Not Provided'
)
return {
type : 'text',
text : `${pipe_abbrv} ${pipe_diam}`
}
hi... we manage to label it ... thank you so much
When is a good function for this, as @JohnEvans6 demonstrates well. I'd also like to suggest using Decode, for when you're simply rewriting the contents of an entire field. You point the function at the field you're using, then supply a series of matching values, then a fallback at the end.
return Decode(
$feature.Pipematerial,
'Mid Steel', 'MS',
'Unknown', 'UNK',
'Asbestos Cement', 'AC',
$feature.Pipematerial
)
If no match is found, it will return the unabbreviated value at the end.
hi... we manage to label it ... thank you so muchh