# Rendering polygon by two variables in QGIS

I have a set of polygons with two variables `"variable 1"` which can take values A, B, C, D, and E and `"variable 2"` which can take values V, W, X, Y and Z.

I would want to render the polygon by the crosstabulation of these two variables. So the legend might look something like this:

I could do it by concatenating variable 1 and variable 2 and individually specifying the 25 colours, but I wonder if there is a more elegant solution already implemented in QGIS?

• Have you seen this thread before: gis.stackexchange.com/questions/315340/… ? Commented Jun 25 at 8:24
• Use a similar technique to that link, have the A-E layer coloured as per your palette, and above that the V-Z coloured grayscale, then set the blending mode so that V-Z modifies the base colour. Commented Jun 25 at 9:36

We can achieve this by combining Categorized symbols based on 'Variable 1' with color lightness based on 'Variable 2'.

Categorize symbols based on 'Variable 1' as follows:

Then select each colour and apply an expression to each fill colour as follows. 'Variable 2' is used to adjust the lightness of the colour:

`````` CASE
WHEN  "Variable 2" = 'V' THEN lighter( @symbol_color, 125)
WHEN  "Variable 2" = 'W' THEN lighter( @symbol_color, 150)
WHEN  "Variable 2" = 'X' THEN lighter( @symbol_color, 175)
WHEN  "Variable 2" = 'Y' THEN lighter( @symbol_color, 200)
WHEN  "Variable 2" = 'Z' THEN lighter( @symbol_color, 225)
END
``````
• Elegant. Just for further explanation. The values in the function set the translucent levels. That ranges from 0 to 255. Commented Jun 25 at 20:55
• Thank you. I believe lighter() sets the brightness not the translucent level (transparency). docs.qgis.org/3.34/en/docs/user_manual/expressions/… Commented Jun 25 at 23:23
• Ha! My mistake. I thought this was setting the A value for RGBA. Commented Jul 1 at 5:29