I have a new model that tries to create a new column using the Advanced Field Calculator and pre-calculated values. I just seem not able to get the syntax right on how to populate the attribute using the values stored in the Variable. Here is my example model. enter image description here

The input data is depicted below enter image description here

Basically what I am trying to do is fix up some bad geometries and then reclassify the layer based on attribute values. I have tried the following formula:

 Case when attribute(get_feature(@layers,@InputFields,'WC')) then 1 ELSE NULL END 


Case When layer_property(@layer,@InputFields) = 'WC' then 1 else 2 end

All of the above formula do not give a clear answer. I have searched the browser for different answers but I haven't got any hints why I am getting an error when I execute the model.

Any hints or links to documentation.

  • I guess it'd be helpful if you shared a bit more about the vector layer you are using as input, maybe even example data and your model.
    – Erik
    Commented Sep 24, 2020 at 14:55
  • I have added more context and example showing the attribute table Commented Sep 24, 2020 at 15:04

1 Answer 1


A correct syntax is this one here:

if (get_feature (@layer,  @InputFields , 'WC'), 1, 0)

Or, using case:

when get_feature (@layer,  @InputFields , 'WC') then 1
else 0

However, you don't provide enough information to see if that is what you want. The help in the expression editor is quite good and gives you ideas about the expressions available, the attributes expected and the syntax.

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.