Looking for assistance to set up appropriate configuration to enable drop-down lists values to be filtered based on a previous value.

Basically, I have a 3-tiered categorisation structure to one of our GIS layers - Class > Type > Sub Type.

Once Class has been selected I would like the Type list to be filtered to only values relevant for that class and so on for Sub-Type.

enter image description here

I have turned this into Code Value list attribute tables and loaded inot QGIS as attribute tables -

enter image description here

I have used these tables as Value Relation lists in the widget properties

enter image description here

The drop down lists work fine without a filter. But as soon as I try adding a filter with an expression, there is nothing in my drop down... If I simply type "CLASS_ID" = 1 ... I do limit the list to only those for Class = 1. The expression on it's own (attribute($currentfeature, 'LU_CLASS') correctly populates the integer values if I use it to populate a virtual field in the expression builder...

Can anyone provide any guidance as to why this doesn't work in the widget filter?

I have also (briefly) tried to set up a relation in the project properties... but this feels like I am going about it the wrong way... the records aren't a child or related to this other table - I simply want to use them to populate drop-down lists.

Am I just missing a simple step?

  • Would this core feature already be what you want? gis.stackexchange.com/questions/156039/… Commented Nov 17, 2015 at 15:54
  • Hi Matthias, this other question was also posted by me (after I had little feedback on this one and did a bit more experimentation myself) - it kind-of works, but requires far more setup and overcomplicates what should be relatively simple. As I understand it, the "relation reference" is for true parent-child dependencies, such as a pole or feature that has multiple connections to it. The suggestion below of a "$currentformfeature" expression sounds great to me, and like it would make the above situation work.
    – Jamie
    Commented Nov 17, 2015 at 22:32

3 Answers 3


$currentfeature refers to the related layer (Type_Values in your example) so the expression always return false and all values are filtered out.

See: https://lists.osgeo.org/pipermail/qgis-developer/2015-November/040382.html

  • This sounds like a wonderful suggestion! Would be very keen to see this implemented so that the above workflow example would work :)
    – Jamie
    Commented Nov 17, 2015 at 22:48
  • ermm am i missing something? nothing comes out of that link
    – Luffydude
    Commented Oct 15, 2019 at 9:16

I've just published a plugin that allows for drill-down and other complex filtering of values in a form, have a look:



I needed something similar and in my case I made it work changing your expression:

"CLASS_ID" = attribute( $currentfeature, 'LU_CLASS')


"CLASS_ID" = current_value('LU_CLASS')

Brief explanation:

As @elpaso66 noticed $currentfeature refers to the related layer (Type_Values in the example above) and we need a reference to the element being edited at the time, so we have current_value('field') function that allows us to select the value of a field in the element that we are editing.

This way we can filter the key of the related layer (Type_Values in the example above) with the value of the fileld we want to use as filter (LU_CLASS in the example above)

  • 2
    Welcome to GIS.SE! Could you please present your answer in more detail so that other users can follow your solution approach more easily? Thanks!
    – root676
    Commented Oct 2, 2019 at 12:59

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.