We are using views to build dynamic tables of utilization and enrollment. When mapping, however, the schools that meet both thresholds both display, and I can't figure out how to remove the labels from one layer if the same feature is in the 2nd layer:

enter image description here

I have seen other posts that discuss using the get_feature() expression builder, but I can't see how to get that to work.

Here's an attempt trying to hide the labels from the enrollment layer if the schnum is present in the Current Utilization layer using a label expression:

when schnum in (get_feature( 'Current Utilization', 'schnum', '*')) 
then ' ' 
else abbreviation 

But that doesn't seem to work, and I can't find much documentation to explain if this is even possible.

  • Just looking at the code in your expression, you may need to add single quotes around the field name 'schnum', unless you already have them.
    – jbgramm
    Feb 28, 2018 at 0:01

2 Answers 2


get_feature() returns the first record which matches with the third parameter. As you have been trying to give it wildcard, I am sure you are not interested in its attribute (second parameter) itself.

I would recommend to use refFunctions plugin:

WHEN geomintersects('Current Utilization', $geometry)
ELSE abbreviation
  • Hmm that doesn't seem to do what it looks like it should do... and it drastically slows down rendering when used in a label expression... Feb 28, 2018 at 20:11
  • @DPSSpatial Thanks for your feedback. It is really unfortunate. Is it the same system (OS environment) which you had issue with time manager plugin, perhaps?
    – Kazuhito
    Feb 28, 2018 at 23:44
  • 1
    Syntax for this function is: geomintersects(targetLayer,targetField), and it returns the value of targetField for the intersected geometry in targetLayer. So your expression should be: if(geomintersects('Current Utilization', 'schnum'), "abbreviation", ' ').
    – csk
    Mar 5, 2018 at 18:54
  • @DPSSpatial Please see the above comment by csk.
    – Kazuhito
    Mar 6, 2018 at 11:21

I have not seen that before.

I am sure there is a reason you may not want to do this,

Add a (label) field to the enrollment layer.

Then join the two tables by school name or number.

Then add a "yes" or "no" or a space or any other text to the (label) field of the rows where there are two school names or numbers.

Then break the join.

Label the enrollment layer contingent upon the label field being populated.

This would be a quick and dirty solution, unless I am totally misunderstanding the question.

  • hah thanks - I think I see what you're getting at. I might have to do some back-end re-design of the views... I'll try this out failing anything else. Thank you!! Feb 28, 2018 at 20:12
  • I made a bunch of assumptions as to what you were doing, what you were working with, and so on. I often create workarounds just to get something done until I can (hopefully) create a more efficient solution. Is it safe for me to assume that you are not using shape files for the vector layer types?
    – jbgramm
    Mar 1, 2018 at 2:03
  • PostGIS... but I figured out an all-too-obvious solution I'll post tomorrow... Mar 1, 2018 at 3:12

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.