I got a feeling I'm missing something very simple here, but how can I use the modeler in QGIS to do the following tasks:

  • Adding/Removing a field
  • Looping through a field
  • Calculate field values based on other fields

I can only find how to do new layers and work with them - but most of the time, I already have the layer loaded in QGIS - I just need to edit the fields. Processing modeler to update table suggests to use the Network plugin, but even then I can't get it to work.

"Update field" algorithm from the network plugin

My understanding was, that the layer has to be connected with the field calculator in order to work, like in QGIS 3 Graphical Modeler field calculator with attribute's parameters but when I choose a vector layer as Input in the model builder, I can't choose my existing layer.

How am I supposed to connect them then?

Until now, I used PyQGis to do these basic tasks, but my shapefile is too big and I was hoping the modeler loops through a big attribute table a bit faster.

  • Could you clarify why you are trying to do this in a model instead of opening the field calculator?
    – Erik
    Mar 12, 2021 at 14:28
  • @Erik because I have to do this task (or similar ones) multiple times on multiple layers
    – Jonas
    Mar 12, 2021 at 14:29
  • And where exactly is the "loop" in this task?
    – Erik
    Mar 12, 2021 at 14:31

1 Answer 1


You can use "refactor fields" tool to add or remove fields as well as to calculate fields based on other fields or values.

First click on the "123" button and choose "model input" to use a input file of the model or "algorithm output" if you want to use the result of a previous calculation step of your model:

enter image description here

Then you can add, remove or change fields as you like.

The "loop" as you say, will be performed automatically on all features of a layer.

If you want to "loop" over several layers, you can run the model as batch process:

enter image description here

  • I tried like this, and it ran the model - but nothing happened. I got no new field in the attribute table - what did I do wrong? The expression is correct
    – Jonas
    Mar 12, 2021 at 15:31
  • @Jonas you missed to add an output layer
    – MrXsquared
    Mar 12, 2021 at 15:45
  • The question is about modifying an existing layer though, not creating a new output. May 15, 2022 at 17:42

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.