I'm trying to implement the new conditional branch algorithm in a model with the following statements:

if( @Udtræk_til_grøfter_OUTPUT  > 0, true, false)

if( @Udtræk_til_grøfter_OUTPUT  <= 0, true, false)

The "branching" works fine, it runs either if they are true, however, it is not consistent with what I know is in the data I feed it with. So I'm suspecting the @Udtræk_til_grøfter_OUTPUT variable doesn't contain what I thought it did. Come to think of it, it probably contains an array with rows? It is the output of an extract by expression algorithm:

enter image description here

What I want to do is get the number of rows in that extraction and match it against the above condition, but I'm not sure how to do that?

1 Answer 1


You can create a column with the result of a test (in your case the result of the 'if'), use a "Extract by attribute" and use this as input for the another step (in this case only the matched). the "Extract by attribute" the "branch"

If you don't want this column in the result, you can drop it.

This seems like another workaround (this I did not try): QGIS Modeler if/else condition, custom script for Modeler

I don't know if this is by design but the conditional branch doesn't work on a feature-by-feature basis (some features in a layer can go to one branch and other go to other branch). Always when I try to get some attribute from the $currentfeature, the test returns false (tried testing if(attributes()['column-name'] is null, TRUE, FALSE) and the results was TRUE. When I try to print attributes()['column-name'], it returns a expected value). This seems related https://github.com/qgis/QGIS/issues/39119

  • An Answer in GIS SE is supposed to answer a Question. Starting out with "Same Question" indicates that this Answer should be deleted as an "I have this question too" response, but you have just enough content here to suggest that, while it doesn't answer the question, it might offer an alternative. I suggest you either make this into an answer or delete it.
    – Vince
    Nov 15, 2020 at 17:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.