I am creating a new field with two existing fields and the result has to be like 1234_Abcd. I used the string concatenation in the Field Calculator but it gives me 1234Abcd. How can I insert the underscore (_) to separate both expressions?


1 Answer 1


You can use

concat("Fieldname1", '_', "Fieldname2")


"Fieldname1" || '_' || "Fieldname2"
  • 2
    Another option would be to form an array with the field names, then use string to array with underscore as the separator. Also using doublequote would evaluate the field and return the feature attribute, once the proper field name is formed, if needed afterward use the attribute function.
    – Al rl
    Commented Feb 4, 2023 at 16:57

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.