Select to view content in your preferred language

Formatting text strings as numbers no longer works

469
2
01-24-2024 09:35 AM
KaraUtter2
New Contributor III

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?

 

0 Kudos
2 Replies
DanPatterson
MVP Esteemed Contributor

python

# for field calculations substitute PM_TOT_VAL with !PM_TOT_VAL!
#  your field is a text field, hence conversion to float and back is needed

PM_TOT_VAL = "608945"  # sample value

'{:,.0f}'.format(float(PM_TOT_VAL))  # -- just commas
'608,945'

'{:,.2f}'.format(float(PM_TOT_VAL))  # -- with decimal places
'608,945.00'

'${:,.2f}'.format(float(PM_TOT_VAL))  # -- throw in some currency
'$608,945.00'  

... sort of retired...
JohannesLindner
MVP Frequent Contributor

Hmm, works in Pro and AGOL for me...

JohannesLindner_0-1706135560106.png

JohannesLindner_1-1706135592464.png

 

Your PM_TOT_VAL looks like a text field. Throw a Number() in there:

var x = "12345"
return Text(Number(x), "$#,###")

Have a great day!
Johannes