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.
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:
Any ideas here?
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'
Hmm, works in Pro and AGOL for me...
Your PM_TOT_VAL looks like a text field. Throw a Number() in there:
var x = "12345"
return Text(Number(x), "$#,###")