4

I have the following function in order to add a sorting value to a layer:

array_find( array_sort( array_agg("field")), "field")

This works fine if I use it through the calculator within the interface (abacus icon) but the same function doesn't work within the field calculator in modeler. The error sais that arrays can't be use it or something like it.

I need to sort a layer or add a rank attribute to a layer from QGIS 3 modeler. I insist: using modeler.

Some screenshots: enter image description here enter image description here

By the way, In the model I'm trying to connect an input "Rank" within the function. That not the problem because I already tried using the simple function I wrote above and It worked. The issue here is the "array_" functions that, within the models, just doesn't work.

1 Answer 1

6

Your expression needs to be in a string format excluding input parameters.

For example, if you want to reference existing fields inside your modeler without adding an input parameter:

'array_find( array_sort( array_agg("field")), "field")'

But if you want to include an input parameter which references a field:

'array_find( array_sort( array_agg(' || @rank || ')), ' || @rank || ')'

or

'array_find( array_sort( array_agg(' + @rank + ')), ' + @rank + ')'

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.