You have a dataset of property assessment values in the town of Portage la Prairie, in Manitoba, Canada. You want to visualize these values on a map in ArcGIS Online , but at first it seems as though you can't, since they are formatted as text instead of numbers. In this tutorial, you'll learn how to build an expression with ArcGIS Arcade to convert numbers stored as text to true numeric values.
This tutorial was last tested on August 15, 2024.
This tutorial is also available as a video.
You'll start by viewing the property assessment data on a map and reviewing the Total Value field. You'll attempt to symbolize the map with this field.
A map of the town's property boundaries appears.
The layer's attribute table appears below the map.
You'll visualize this field on the map so you can see which properties have higher values than others.
If the Settings toolbar is unavailable, in the Layers pane, click Portage la Prairie property assessment . The Settings toolbar is only available when a layer is selected.
The Styles pane updates to show styles that are available for the Total Value field. There are only two: Types (unique symbols) and Location (single symbol) . You hoped to use a quantitative style such as Counts and Amounts (size) , but none are available. Near the top of the Styles pane, next to Total Value , the field's type is listed as abc , indicating that it is a string, or text field. Numeric values are required to use the Counts and Amounts style. It won't work with text values.
You can still symbolize the map with the Total Value field and the Counts and Amounts style. You will use an Arcade expression to convert the text values into numeric values.
The Functions pane appears, listing all the available Arcade functions.
The function appears in the expression builder. The value_ parameter is highlighted. Next, you'll replace it with the Total Value field, so leave the parameter highlighted.
Profile variables are data variables from the map that you can use as inputs in your Arcade expression. They include all of the fields from the layer. In the Profile variables pane, $feature refers to the features in the layer. In this case, the features are properties in the Portage la Prairie property assessment layer.
A list of all of the fields from the Portage la Prairie property assessment layer appears.
The expression updates to Number ($feature.Total_Value) . The first parameter, value , is now defined as $feature.Total_Value . The expression will access the Total Value attribute from each feature in the layer. The next parameter, pattern , is optional, so you'll run the expression to test if it works without defining a pattern.
In the Output window, the output Number: NaN is reported. NaN stands for Not a Number. In this case, the expression did not work with an undefined pattern.
The # character signifies an optional digit in the Number function. The #.## pattern will convert any amount of digits before the decimal and up to two digits after the decimal. The values in the Total Value field are monetary, so there's a possibility that some may be expressed with up to two decimal places. This pattern will ensure that values with decimal places can be converted.
The Output window still reports Number: NaN . Next, you'll consult the function's documentation to find a solution.
You recall from the attribute table that each number in the Total Value field was prefaced with a $ character. This is a text character. The expression is failing because it can't convert the $ character into a number. You'll consult the Number function's documentation to see if there's a way to remove the $ character.
The function's documentation appears.
The second example shows how to ignore certain characters when converting text to numbers. Number('abc10def', 'abc##def') // return 10 . In the example expression, abc and def are defined as text that should be ignored. You can use this pattern to ignore the $ character.
The final expression should read Number($feature.Total_Value, '$#.##') .The Output window reports Number: 85200 . The expression was successful in converting values like $85,200 into numbers like 85200.
If your web browser is set to a language other than American English, the expression may fail due to the commas used as thousands separators. If the Output window still reports Number: NaN , erase the existing expression and replace it with the following:
var numberOnly = Replace($feature.Total_Value, '$', '') // Remove dollar signs. var digitsOnly = Replace(numberOnly, ',', '') // Remove commas. Number(digitsOnly)
The map reappears. The Styles pane lists the Total Value (numeric) expression as the chosen attribute. Counts and Amounts (color) has been selected as the default style for the numeric values returned by the expression. The map visualizes the values from Total Value field with larger circles for larger assessed property values.
The Total Value field and the Portage la Prairie property assessment layer are unchanged. The Total Value (numeric) expression is saved in the web map, not in the layer, but if you save a copy of the layer, it will be available for use in other maps.
In this tutorial, you learned how to use the Arcade Number function to convert text values to numeric values for a layer in a map so you could apply the Counts and Amounts style. The expression you wrote— Number($feature.Total_Value, '$#.##') —can also be used to format pop-ups and labels.
You can find more tutorials in the tutorial gallery.
Please send us your feedback regarding this tutorial. Tell us what you liked as well as what you didn't. If something in the tutorial didn't work, let us know what it was and where in the tutorial you encountered it (the section name and step number). Use this form to send us feedback.
Sharing and reusing these tutorials are encouraged. This tutorial is governed by a Creative Commons license (CC BY-SA-NC). See the Terms of Use page for details about adapting this tutorial for your use.