Rule-based vector styling
The rule-based vector style applies one symbol per created rule and can apply maximum and minimum scales to toggle symbol visibility. This vector style is best when you want a different symbol that is based on different expressions or when you want to display different symbols for the same layer at different map scales. For example, if you are styling roads, a rule could be set to make roads appear as thin lines when zoomed out, but when zoomed in, the thin lines will disappear and be replaced by thicker lines that are more scale appropriate.
There are no default values for rule-based styling; however, if a style was previously set using a different styling type, the style will be converted into rule-based when this style type is selected. The following screenshot shows the Categorized style type from the previous section that is converted into the Rule-based style type parameters for point vector data of surveying levels:

The Rule-based style properties window shows a list of current rules with the following columns:
- Label: The symbol and label that will be visible in the Layers panel are displayed here. The checkbox toggles rule activation; unchecked rules will not be displayed.
- Rule: This displays the filter that was applied to the vector dataset to select a subset of records.
- Min. Scale: This displays the smallest (zoomed-out) scale at which the rule will be visible.
- Max. Scale: This displays the largest (zoomed-in) scale at which the rule will be visible.
- Count: This displays the number of features that are included in this rule. This is calculated when the Count features button is clicked.
- Duplicate count: This displays the number of features that are included in the current and other rules. This is helpful when you are trying to achieve mutually exclusive rules and need to determine where duplicates exist. This is calculated when the Count features button is clicked.
To add a new rule, click on the Add rule button () to open the Rule properties window. To edit a rule, select the rule and then click on the Edit rule button (
) to open the Rule properties window. To remove a rule, select the rule and then click on the Remove rule button (
).
Additional scales, categories, and ranges can be added to each rule by clicking on the Refine current rules button. To calculate the number of features that are included in each rule and to calculate the duplicate feature count, click on the Count features button.
When a rule is added or edited, the Rule properties window (which is shown in the following screenshot) displays five rule parameters, which are as follows:
- Label: This should have the rule label that will be displayed in the Layers panel.
- Filter: This will have the expression that will select a subset of features to include in the rule.
- Click on the ellipsis button to open the Expression string builder window. Then, click on the Test button to check the validity of the expression.
- Description: This has a user-friendly description of the rule.
- Scale range: This has the Minimum (exclusive) and Maximum (inclusive) scales between which the rule will be visible.
- Symbol: This has the symbol that will be used to symbolize features that are included in the rule.
None of the parameters are required (Label, Filter, and Description could be left blank); to exclude Scale range and Symbol from the rule, uncheck the boxes next to these parameters:

As an example, using the Populated Places.shp sample data, capital cities, megacities, and all other places can be styled differently by using rule-based styling. Additionally, each rule is visible to the minimum scale of 1:1, although they become invisible at different maximum scales.
The following screenshot shows the rules that were created and a sample map of Europe and North Africa:
