2

I am using QGIS 3.22 and I am making some algorithm in Modeler enter image description here

I am using Vector Layer as layer and Vector Field as field (it is field with real values and nulls). I want to add column with sum of field. So in Field calculator I use following formula

*sum(@

As a result I get NULL field instead of my input field and the following error message is shown:

Eval Error: Cannot use aggregate function in this context.

How to use aggregate functions correctly?

enter image description here

2
  • Please provide relevant error messages.
    – Erik
    Commented Feb 27, 2023 at 15:51
  • @Erik Eval Error: Cannot use aggregate function in this context Commented Feb 27, 2023 at 17:30

1 Answer 1

5

This is a bit tricky in QGIS - may be it is an error because it is not logical, which QGIS mostly is - but anyway, you have to change your formula to precalculated value and then make a string representation of your formula like:

'sum(' || @field || ')'

enter image description here

1
  • Worked like a charm!
    – chjch
    Commented Jul 5, 2023 at 1:38

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.