I seem to have a problem with the default value in one of my colums by the calculator expression.

I have two specific columns that have widget input one being tekst value and the other being numbers

These are called PlotL and PlotC. At the end there is third column which will have a new value which just is the merging of two value's in those two columns.

So I have made the expression PlotL || PlotC as the "default value" of that Third Column. And the example does give the result what I want. But here is the kicker, after the object is added/Created and I open the Attribute Table, it is still NULL. Now I have searched before here for a simular question and that sollution was just to save my edits and go out of my edits. But after that still nothing.

What is going on here and what I am doing wrong?

The Attribute Tabel

Default Value setting

After Edit Save

  • Usually it should be "PlotL" || "PlotC" (in doubleqoutes). But besides that I assume it is due to a wrong field type. What type did you set for "Plot" (String, Double, etc.) and what should it be?
    – MrXsquared
    Commented Jun 6, 2019 at 11:27
  • PlotL is in String with a value map set to it. PlotC is in numbers from 1-20. It should be converted into a string type because this will be used for Querrys in the future. So what should I do? Commented Jun 6, 2019 at 13:03
  • Check if "Plot" has the fieldtype string. If not change it or recreate it with that field type.
    – MrXsquared
    Commented Jun 6, 2019 at 13:10
  • It has string and all of the fields have the datatype they need to be. Commented Jun 10, 2019 at 20:23

1 Answer 1


Either of these should work. See notes below for further explanation.

concat( "PlotL",  to_string("PlotC") )


"PlotL" || to_string("PlotC")


to_string converts a number into a string

Double quotation marks around field names are optional, but still a good idea, especially if:

  • your field names have spaces
  • your field name may be confused by the expression builder for a function or conditional (eg, if, when, case etc.)

QGIS has two concatenation methods, || and concat(). Each method has its uses.

  • If you use the double vertical line symbol || for concatenation, if any of the inputs are null the entire output will be null. This method is best if you want the complete string or nothing.

  • If you use the concat() function, any null inputs will be converted to a blank string. So the output will be whichever of the inputs was not null. This method is best if you would rather have a partial string than nothing.

  • Thank you for your response but it does not seem to solve the problem I have so far. It seems I have to find a way around this and not automate this at all. Thank you for your response and feedback. Commented Jun 11, 2019 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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