4

I am building a model that includes a 'select by attribute' algorithm, and I am attempting to select by multiple fields where the value matches a model input.

Essentially, I want the selection query to be 'field1 = input AND field2 = input'

Based off the tooltip, and this question (Select multiple fields in Modelbuilder) I believe that the syntax for selecting by multiple field parameters should be field1;field2:

enter image description here

However, this is not working for the select by attribute tool. The dialog box closes and clears the 'Selection attribute' field when I hit OK.

Is there a different syntax for the select by attribute tool or is this not possible? I am able to work around it for now by having two 'select by attribute' algorithms in the model and selecting within the current selection. I am using QGIS version 3.16.

asked Dec 4, 2020 at 15:44

1 Answer 1

2

You can't input two fields at once here with this function. The function select by attribute has only one possible input for the selection attribute when you run it standalone from the toolbox. So I guess it will not accept more inputs in the model as it is not designed for that.

The question you linked to has apparently the built in capacity to select more than one input fields as you can see from the optional plural form: Dissolve field(s) - and there, it really makes sense.

But with select by attribute, you have only the singular form: Selection attribute.

If you had two inputs field, QGIS would need an additional possibility to know how these two fields are combined: field_1 = School_Code AND field_2 = School_Code ? Or rather: (field_1 OR field_2) = School_Code?

So I guess your best option is to run select by attribute twice. Or you can try select by expression where you are free to define complex expressions.

answered Dec 6, 2020 at 16:07

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.