I am wondering if there is a way to add unit (m,ft etc) in a column of numbers in a attribute table in QGIS. I want to do this so when I post the text the units can be posted as well. I am working with pressure data so i would like to the Kpa after the number.

  • 3
    Please do not post questions with ALL CAPS titles. In addition to being more difficult to read, doing so will encourage downvotes. Is there a reason you can't add a units column to the table? – Vince Jan 3 '19 at 17:32

No, you can't store UoM (units of measure) in a numerical field. UoM is text, which is not compatible with the numerical format. It's common practice to include the UoM in the field title, eg instead of calling a field "Area" call it "Area_ac" (for acres), "Area_ha" (for hectares) or "Area_sqm" (for square meters).

If you want the UoM stored in each field, you can create a new field in text(string) format, and copy over the values from the original column. Because this is a text field storing mixed numbers and text values, you won't be able to do mathematical functions, not even with the to_int() function to convert a string to an integer.

If you simply want to display the numerical field with UoM, say as a label, you can use the expression builder to add UoM to the label. Eg, with a field called "Area_sqm", label with this expression:

"Area_sqm" || ' sq m'

or this:

concat("Area_sqm", ' sq m')
| improve this answer | |
  • Or, even shorter "column-name"||' unit' – Erik Jan 3 '19 at 18:13
  • face palm I'm too used to concatenating multiple columns... – csk Jan 3 '19 at 18:16
  • Don't worry, my first model from a year ago is a leviathan of unnecessary concat. Also, basically your original solution was both right and more easily understandable. – Erik Jan 3 '19 at 18:19
  • If I successfully answered your question please accept it by clicking the check mark next to the answer. This helps other users know that this answer was useful. – csk Jan 3 '19 at 22:12

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.