You can write your equation in a new function, and then you would only have to call the function to re-apply the computation.
Open the field calculator, click on the Function Editor
tab, new file
then edit the function. Select load
. Note that ok
will not be available at this point.
Go back to the Expression
tab, select the custom
function group and double click on your function. Select the field to be updated, and hit ok
.
If you want to only use field values and constants, you can edit the default function signature, which starts with value1
. In my example I have removed it, but you could use this field(s) to pass new arguments.
You can then access the feature field values using feature["fieldName"]
.... be carefull to call this function only on layers containing the said fields!
@qgsfunction(args='auto', group='Custom')
def funcTestCalc( feature, parent):
return feature["fieldA"]+feature["fieldB"];