I am using a rule based styling only to show certain polygon which match with below filter:

"NAME_2"  = 'Probolinggo' OR "NAME_2"  = 'Kota Probolinggo'

The layer has thousands of polygon, so I need to filter only to show certain polygon with above filter rule.

But I want the displayed polygon to have random color on it just like when we do on "categorized style". Is it possible?

enter image description here

so basically i just want to display random color on yellow line polygon which filtered based on using "rule-based" styling

enter image description here

the yellow line polygin supposed to consist thousands of polygon, but i filtered out just to show up on certain area. so it will looked like this

enter image description here

  • Categorized symbols don't have random colours, they have colour based on the category they are in. Please specify what you want to achieve.
    – Erik
    Sep 21, 2022 at 13:20
  • hi @Erik thank you for respond, i edit the question to make it more clearer to understand. Sep 21, 2022 at 14:21
  • Sorry, this doesn't make anything clearer. Can you provide an example of how the map should look like?
    – Erik
    Sep 21, 2022 at 14:25
  • sorry to make you confuse, i edited again the question. Sep 21, 2022 at 14:46

3 Answers 3


There are many way to do what you need depending on you environment and limitations.

I think the most straightforward one would be:

Possible solution 1: Use your formula in the filter option (right click on the layer/filter..) instead of in the styling, then you will be able to use the categorized styling the way you are used to.

Other solutions may include:

  • Use the categorized random styling on you layer and remove all the other categories manually
  • extract the features you want to visualize and then apply styling ...
  • you're definitely answer my question. than you Geotyr Sep 21, 2022 at 14:58

You can go under categorized symbols, and use something like that:

WHEN "NAME_2" IN ('Probolinggo', 'Kota Probolinggo') THEN $id

And then you just need to uncheck "all other value".


You can use rule based and then use "refine" in the bottom left corner for each rule (se picture below though it´s in Swedish). Then it´s a simple matter och choosing a unique data field like ID and classify. All random colors assigned to each ID will appear under the main color for the rule and these sub-colors will be rendered instead of the rules main color. The randomized colors are permanent categories and won´t change with changed data (I think) and you can add or subtract colors/sub categories with the plus and minus sign. I have a project where I know I had done this but I could not remember how. So, I spent like 3 hours figuring out again...

enter image description here

enter image description here

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.