2

I am new to QGIS (ESRI shop at work). I am attemping to concatenate fields in the label expression

field1 = number
field2 = number

label expression I tired but fails

str(field1) + " - " + str(field2)

it says its not valid. This would work in ArcMap... how is it different?

Ian Turton
  • 81,417
  • 6
  • 84
  • 185
NULL.Dude
  • 2,131
  • 2
  • 14
  • 32

2 Answers2

5

You need to change three things about your query:

  • The conversion to String is done by to_string rather than str
  • Strings are surrounded with ' rather than "
  • Field names are surrounded with "

So your query should look something like this:

to_string("field1") + ' - ' + to_string("field2")

karpfen
  • 2,307
  • 1
  • 17
  • 32
4

You can use the concatenate operator || or the concat function (under strings).

Ian Turton
  • 81,417
  • 6
  • 84
  • 185