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

Matt
19.4k4 gold badges25 silver badges64 bronze badges
asked Feb 27, 2023 at 15:39
2
  • Please provide relevant error messages. 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

answered Feb 28, 2023 at 6:00
1
  • Worked like a charm! Commented Jul 5, 2023 at 1:38

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.