2

I would like to update one ore more fields of my attribute table on demand (f.e. using a QGIS Action) with one simple click.

For now I have to open attribute table or the layer properties, start field calculator, choose the field I want to update, type or paste my expression and run it for every field I need to update.

I tried to use the model builder but I found no way, to simply update a field within the layer without creating a new layer.

Virtual Fields are not helping me in this way, because the recalculation will be time consuming (complex aggregate expression).

7
  • Is this for adding new fields to a layer or updating existing fields of a layer? Commented Oct 20, 2020 at 10:40
  • updating existing fields in a layer Commented Oct 20, 2020 at 11:44
  • So you have some preexisting fields in a layer and you need to run the field calculator for them individually, I'm sorry if I'm not understanding correctly but I don't see why virtual fields would not work. Once you set them up once then you don't have to get them to recalculate, they do it automatically. Recalculation won't be time consuming, it will not have any manual input at all. Again, apologies if I am misunderstanding. Commented Oct 20, 2020 at 12:30
  • The expression I want to use for updating the fields is a complex aggregate and is very time consuming. Commented Oct 20, 2020 at 13:38
  • Hello @MartinMap, have you find a solution to use action for attribute edition/update ? Commented Jul 17, 2022 at 7:52

1 Answer 1

3

You can do this using virtual fields. In the field calculator check the Create virtual field button: enter image description here

When you add or edit a record or close and reopen the attribute table this will recaulcuate update on the fly.

For example if I create a virtual field for a polygon layer with the expression $area then when I create a new polygon it will automatically populate that field. If I change the size of the polygon then it will update.

You can also change the expression later by going to Layer Properties > Fields and edit the expression in there.

1
  • Virtual fields are nice but no solution in my case. I edit my question. Commented Oct 20, 2020 at 10:37

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.