Select to view content in your preferred language

How to use abbreviation labelling in arcade ArcGIS online.

883
5
Jump to solution
02-05-2024 07:14 PM
NadiaAlami
Occasional Contributor

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. 

NadiaAlami_0-1707188877297.png

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

 

0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

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.

- Josh Carlson
Kendall County GIS

View solution in original post

5 Replies
Amir-Sarrafzadeh-Arasi
Frequent Contributor

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

Amir Sarrafzadeh Arasi
JohnEvans6
Regular Contributor

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}`
}

 

0 Kudos
NadiaAlami
Occasional Contributor

hi... we manage to label it ... thank you so much

0 Kudos
jcarlson
MVP Esteemed Contributor

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.

- Josh Carlson
Kendall County GIS
NadiaAlami
Occasional Contributor

hi... we manage to label it ... thank you so muchh

0 Kudos