I have 2 different layers: one is properties and the other one is park buffer. I would like to add a field in the properties attribute table that says YES if "properties" and "buffer" intersects, and if they dont that it says NO; with possibility to later add if it intersects with 2 different layers.

I have tried with:

if 'properties' overlay_contains 'buffer' then 'yes' else 'no' - but this gave me an invalid expression

i have also tried with: if 'array_to_string(overlay_within('properties', buffer))' then 'yes' else 'no' - but still not working. I'm not super good with programming and I'm quite new to QGIS but eager to learn. Does anyone know if this is possible? if yes... how can i fix it?

  • Have you at least had a look at the tooltip the field calculator provides for the if() expression?
    – Erik
    Aug 26, 2022 at 14:00

1 Answer 1


The expression to use is much easier: overlay_intersects ('park buffer'). It return true/false. If you set field type to integer, you get values of 0/1.


Syntax for if()-funtion with output (as string): yes/no:

if (overlay_intersects ('park buffer'), 'yes', 'no')

Alternatively, with same result, using case statement:

case when overlay_intersects ('park buffer') then 'yes' else 'no' end

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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