Formatting Text Strings with Arcade no longer works on hosted feature services

366
1
Jump to solution
01-24-2024 09:37 AM
KaraUtter2
New Contributor III

Is anyone else having this issue and how have you solved it?

 

Is anyone else seeing the below issue in both ArcGIS Online and ArcGIS Pro (when connected to the hosted feature service)?

Using Arcade to format text strings as numbers with dollar signs and thousands-separators is no longer working like it used to. This is very frustrating because it's incredibly useful when creating online maps and apps from data that has numbers in a text field. Many datasets come this way and Arcade is supposed to help save us save time by creating those labels via expressions on the fly instead of having to add number fields and calculate the values from the text fields. Having to add fields means there are more fields to maintain, it adds work during updates, and is just a pain.

First, here is the basic ESRI help page that describes the Arcade expression to be used which is quite simple:

How To: Add Thousands Separators to Labels in ArcGIS Pro (esri.com)

Here is an example of me attempting to run this calculation on a hosted feature service in ArcGIS Pro - as you can see the Comments field shows the exact same text string without the additional formatting of the thousands separator.

KaraUtter2_0-1706117551027.png

Here are my attempts at running this same expression in Map Viewer field expressions and the result which still does not have the thousands separator or a dollar sign:

KaraUtter2_1-1706117600481.png

KaraUtter2_3-1706117643670.png

 

KaraUtter2_2-1706117614021.png

 

Any ideas here?

I also posted this to the ArcGIS Pro community:

https://community.esri.com/t5/arcgis-pro-questions/formatting-text-strings-as-numbers-no-longer-work...

0 Kudos
1 Solution

Accepted Solutions
EmilyGeo
Esri Contributor

Hi @KaraUtter2 , 

Formatting a numeric field this way is working for me in both Pro and Online.

What is the field type for the field you are using in the expression? It sounds like you may be trying to format a text field using the text function. I'm not sure that's supported. The text function is typically used to format other (non-text) field types, such as double, integer, float, etc.

But, you can still use Arcade to get the results you want. One option is to cast the text to a number first, then you'll be able to format the resulting number using the text function.

For example:

var mytext = $feature.nameofyourtextfield*1
return text(mytext, '$#,###')

 

View solution in original post

0 Kudos
1 Reply
EmilyGeo
Esri Contributor

Hi @KaraUtter2 , 

Formatting a numeric field this way is working for me in both Pro and Online.

What is the field type for the field you are using in the expression? It sounds like you may be trying to format a text field using the text function. I'm not sure that's supported. The text function is typically used to format other (non-text) field types, such as double, integer, float, etc.

But, you can still use Arcade to get the results you want. One option is to cast the text to a number first, then you'll be able to format the resulting number using the text function.

For example:

var mytext = $feature.nameofyourtextfield*1
return text(mytext, '$#,###')

 

0 Kudos