In the ArcGIS Online field calculator I am trying to combine a few other fields into one (address field) and cannot figure out how to put a space between the fields. I am sure it is something simple, but I am unable to find the answer elsewhere. Please help! I've tried everything I can think of.
Solved! Go to Solution.
Two methods of concatenating 3 variables with a space in this post. I'm going to summarize both methods so the solution is clear. For this example feel free to use the layer mentioned below. I have left it editable, so that you can test out the differences of the two methods . Using Arcade is the most straight forward and flexible depending on how you plan to use the created field.
Example Web Map and layer
Create an Arcade expression for displaying in pop ups (or labels or symbology). Arcade can be used to display formatted data as a new field in pop ups or for symbology. If you are using Arcade, any updates to existing data will be displayed in the expression as the expression is created at the time of the pop up to display up to date values.
1. Add layer to Web Map: https://www.arcgis.com/home/item.html?id=7810a6a9ccd0406fb3b7ce7f10aac818
2. Configure Pop Up > Add Attribute Expression
3. Add Expression: Concatenate([$feature.dog1,$feature.dog2,$feature.dog3], ' ')
4. Ensure the created expression is checked to display in pop up (all dogs in this example)
Note: If you want to use this expression as a label or for symbolization, Click New Expression and then select the existing expression to use in web map
Calculate a field value in a table. You can calculate a concatenated field using the calculate field to. This is great for one time changes to data sets. The data will be updated at the time of the calculation and then may need to be updated manually or by calculation if the contributing fields were to change.
1. Display data table in Map Viewer or on Data tab of item details page.
2. Add a field to the table (Calculated Field)
3. Ensure the Field is displaying in the table and select calculate
4. Enter the following calculation:
CONCAT(dog1,CONCAT(' ', CONCAT(dog2,CONCAT(' ',dog3 ))))
5. Verify that the calculated field displays correctly.
Do you need to perform this with field calculator and store this within a field, or would creating an expression using Arcade get you up and running?
I've been trying to figure this one out with a concatenate but no luck:
Throws an error of 'Unsafe sql expression is not allowed'
This is from the online help as an example:
Concatenate(['red', 'blue', 'green'], '/')
Which is what I used to fashion my expression, but it fails with the same error.
Seems like adding a white space shouldn't need to be so difficult....
Ensure that your fields are referring to features in your to your feature data and that you use the full Concatenate when referring to the function.
Check out the quick example in this web map:
The All Dogs field was calculated using the following expression:
Concatenate([$feature.dog1,$feature.dog2,$feature.dog3], ' ')
Rats- doesn't work for me. Sill getting the Unsafe sql expression not allowed....
Just two fields with CONCAT seems okay:
I must be missing something here.....
Are you creating an expression or calculating a field?
Can you send me a link to your web map? Feel free to invite me to a group if you don't want to share the map publicly, Karate_KElly.
I'm just calculating a new field, following what the OP asked about. I work with addresses often so it sounded like something I'll be faced with sooner or later. Invitation sent....
Another reference, another fail:
Concatenate ([$features["fieldname"], "is", "great!"], ' ')
where fieldname contains a value of GeoAnalytics
and allegedly produces:
GeoAnalytics is great!
and it balks with Unsafe sql expression not allowed.....