19

Is there a way to concatenate fields in field calculator of QGIS? (e.g. hectares + ' ha')

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
vascobnunes
  • 5,570
  • 13
  • 49
  • 74

5 Answers5

30

In recent QGIS versions (>= 2.6), + works for string concatenation

tostring(hectares) + ' ha'

Previously, the only concatenation operator was: ||

tostring(hectares) || ' ha'
underdark
  • 84,148
  • 21
  • 231
  • 413
12

Right-Click on the layer -> Properties -> Labels Then you can use the following function "concat(string1, string2,... ) : enter image description here

I hope it will be usefull.

Benno
  • 736
  • 7
  • 16
8

You can also append text or put spaces between using alternate quotations:

 "Streetnum" || ' ' || "Streetname"
nickislander
  • 163
  • 1
  • 6
  • I suggest the readers use this solution rather than the popular solution to combine two integers. to_string("field1") || to_string("field2") – G.S. J Jun 23 '21 at 06:59
3

You can use tostring() to concat number fields Ex hectares || ' ha' || tostring(id)

SkipCody
  • 41
  • 3
1

Yes! Using the field calculator, the syntax is: FIELDNAME || FIELDNAME

EDIT: This works on string fields or string-integer combinations. With Integers, it will just perform the math and add the fields together.

Darren Cope
  • 6,616
  • 2
  • 32
  • 47