I have a question regarding using the Conditional Branch algorithm in the Graphical Model Builder.
I am building a rather complicated model with many branches but not every branch needs to be used every time. So I want to use the Conditional Branch algorithm to check the "art"
column of the attribute table from my input layer and to only run that branch if a given value is present, PX or QX in this particular case.
The model will have at least 15 branches when I am finished but usually only a few will be needed per job.
So, I need to use the Conditional Branch algorithm as a kind of if/else filter where if the value is present it runs the branch elsewise it ignores that branch and moves on to the next one.
How do I set up the Conditional Branch so that it ignores that branch unless the value is present?
(Pic isn't my main model, just an example)
1 Answer 1
I've created a model with an input point layer.
A conditional branch with two conditions:
- If there is an
A
in theart
column: The points get buffered - If not it will create rectangles around the points.
Start by renaming the layer to inlayer
Create a conditional branch with the condition aggregate(layer:='inlayer', aggregate:='count', expression:="art", filter:="art" IN('A'))>0
It will count the number of values in the art column where the value is A. If more than 0 the branch will be True.
Create another branch with the opposite condition:
aggregate(layer:='inlayer', aggregate:='count', expression:="art", filter:="art" IN('A'))<1
Use the branches as dependecies to the next algorithms: enter image description here
Explore related questions
See similar questions with these tags.