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'
Hi Dan, I don't think that works in the field calculator in ArcGIS Pro. Also, using Arcade for this need worked for years. I have been using that same expression for a long time, it should still be working. I don't want to use python for something that should still be functioning appropriately in Arcade. Thank you for attempting a solution for me. If this solution involved Arcade, it would meet my needs better.
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), "$#,###")
Hi @JohannesLindner, my PM_TOT_VAL has numbers in the fields - please look again. They are all numbers. Also, I don't see the result in your photo of ArcPro that shows that the commas were added appropriately to reflect thousands? So, I still don't see that it's working the way that it should.