Within a single polygon shapefile, describing the geological regions of Canada, I have 5 attributes I am hoping to combine to present a cohesive symbology. For the Legend I would like to display data from the "GENETIC250" field and, where that is blank, from the "GENETIC1MA" field. These data will also be ideally represented using the RBG values given within the 3 relevant columns. This last step is done easily enough, i.e.color_rgb("RED","GREEN","BLUE"), but I am struggling to incorporate the other expressions into the symbology.

Using QGIS 2.18.x, can anyone suggest a solution?


2 Answers 2


Perhaps try a conditional. For example if you are using categorised symbology, under Column you could put

if("Genetic250" IS NULL,"Genetic1MA","Genetic250")

Then you will get symbols for all values of Genetic250, and where that is null then you will have symbols for all values of Genetic1MA (only where Genetic250 is null - this distinction should be made clear to anyone using the data).

You can also use this to individually set values for your symbology, for example if("Genetic250" IS NULL,"Genetic1MA","Genetic250") = 'ridged till' will display features #10690 - #10693 in your data.

Whereas if("Genetic250" IS NULL,"Genetic1MA","Genetic250") = 'rogen moraine' will display features #10688 - #10689 even though #10690 - #10693 also have the same Genetic1MA value.

If that is confusing you could use "Genetic250" = 'ridged till' and "Genetic250" IS NULL AND "Genetic1MA" = 'rogen moraine' for the above two situations respectively, but it's easier to make mistakes...

How are you implementing the colour symbology? As far as I am aware, using data-defined overrides for colour will not show up on the legend (How to style a vector layer in QGIS using hexadecimal color code stored in attribute?)


The function to use is named coalesce(a,b). The first not-null values between the two parameters is returned.

You would use the label expression coalesce(GENETIC250,GENETIC1MA)

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.