Bug report #17300
Aggregate functions in Field Calculator in modeller
|Affected QGIS version:||2.18.14||Regression?:||No|
|Operating System:||Easy fix?:||Yes|
|Pull Request or Patch supplied:||Yes||Resolution:||fixed/implemented|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||25198|
The aggregate functions in field calculator cannot calculate on a layer which is not saved to the project model.
For example, when trying to do a series of aggregate (e.g. mean, sum) calculations in the model builder, the first one (working directly off of a layer saved in the model) will work, while any subsequent calculations, based on temporary layers within the model builder calculations returns "An error occurred while evaluating the calculation string: Cannot use aggregate function in this context".
(I haven't posted issues before, hopefully this is enough detail. It is very easy to replicate -simply try to do a couple of aggregate functions in series in model builder)
#10 Updated by Jean-Louis Stanus almost 5 years ago
I tested with nightly 2.18.16-5 (installed with osgeo4w). It looks not solved.I created
- a model with refactor inwhich i use aggregate( ... input : merged_only_by_model
- a second where i merge 2 layers THEN i refactor inwhich i use aggregate( ... input : couche2 and couche1
The first works, the second with the same layer not because refactor with aggregate is used in second (or more) place
UPDATE: yes, typo. Fixed ;)
#12 Updated by Luigi Pirelli almost 5 years ago
The Aggregate function you are using in "test aggregate only" model is a "refactor fields" qgis alg that has not relation with aggregate functions. The only relation is the name that is set manually in the model.
The "test merge and aggregate" model depend on saga (that I've not installed) do you mind to prepare a test case that use ONLY base algorithm not depending by third party backends? I've error reading the algorithm because lack of SAGS.
BTW, merge algorithm is not (AFAIK) an aggregate function.
all this to say that your report seems related to something not related with the issue that has been fixed.
I leave the issue closed until a reproducible and related test case can confirm that the fix is not working.