1

This question expands on, and updates for QGIS 3, the answers found here.

I have a layer with attributes called "Name" and "Label". I would like to set to default value of "Label" to be the same as that of "Name" unless and until I enter a value for "Label". I used the Attributes Form settings to enter a default value for "Label" of attribute($currentfeature, "Name"); however, since default values are applied only to new features, and the "Name" field has no value until that feature is created, there is no existing value to apply to "Label".

I believe the AutoFields plugin would have worked, as suggested in the linked topic, but this plugin isn't available in QGIS 3. I also tried to use an if() statement, but again, it refers to attributes of the new feature, so it doesn't set the default for that feature.

As a workaround for my specific task, I know that I can use conditional statements in my label settings to use "Name" if, and only if, "Label" is NULL. So the question here is, how can I set a default value for an attribute in a new feature that refers to another attribute in the same new feature?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.