This question has been related to this one:

https://gis.stackexchange.com/questions/370986/making-colours-from-table-with-colour-percentages-rgb-codes

In that scenario I have made sure that my layer has the right colours based on a expression. This is just because this certain dataset has a "standard" we all have to follow.

**The thing is this is based on a **single symbol expression** (aka the hexcode rgb). The colours are right, however when I want to construct a legend by the "ouderdom" layer, the colours of the legend are wrong.** **This is of course because when I try to categorize it by that field, in the legend random colours are chosen, causing the legend to display the wrong colours.**

**So to clarify my symbology of the layers needs to based on the "ouderdom" field categorization but the colouring needs to still happen the same expression (so no random colours), how do I do this?**


To illustrate what I mean I will ad some screenshots here:

Now this is the setting I use to set the right colour to my features in the layer:
[![enter image description here][1]][1]


In this second screenshot I will get a clear coloring like this:
[![enter image description here][2]][2]

Which matches the standard map of the dataset seen here, this is the standard of the legend everyone has to follow in terms of coloring:

https://www.dov.vlaanderen.be/sites/default/files/pfiles_files/tertiairkaartA3_0.pdf




The problem is, as you may have noticed, the legend highlighted in this screenshot here:

[![enter image description here][3]][3]


  [1]: https://i.sstatic.net/OKgtG.png
  [2]: https://i.sstatic.net/64zF1.png
  [3]: https://i.sstatic.net/Q0lMK.png

So now I hope you see and understand what the problem is.