2

I have a column in a large attribute table. The values in this column are numeric value.

Example entries in this case would be:

1, 2.0512, 8.5744, 8.944

How can I add the word 'm' to the end of each entry so it'd look like:

1m, 2.0512m, 8.5744m, 8.944m

I don't want to use the technique of sorting them, then selecting them, then using field calculator to define them. I just want to know how to add text at the end of existing value, no matter what the existing value is.

  • This is in ArcGIS in case they are similar: Using Field Calculator, the expression would be something along the lines of str(!fieldname!) + 'm'. The general idea is that you need to convert the numeric value to string and then concatenate with another string. – smiller Aug 6 '18 at 15:58
  • 2
    Based on this thread gis.stackexchange.com/questions/229786/… it looks like the function in QGIS to convert a number to string is to_string rather than the Python str. But maybe it doesn't have an underscore, per the qgis documentation (look in conversions group) -- docs.qgis.org/2.8/en/docs/user_manual/working_with_vector/… – smiller Aug 6 '18 at 16:00
4

If your original field is a string-type field, you can update it instead of creating a new field.

Use the Field Calculator to update an existing field

  • Check the box next to "Update existing field"
  • Select "oldfield" from the dropdown menu
  • Use this expression* concat("oldfield", 'm')

enter image description here


If your original field type is numerical, you can't add text to it. Instead you have to add a new string-type field.

Use the Field Calculator to create a new field.

  • Output field type: text(string)
  • Use this expression* concat("oldfield", 'm')

enter image description here


*Substitute the actual name of your field where I used the value "oldfield"

  • May work as well "Field_with_values" || 'm' – Taras Feb 19 at 12:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.