# Match Logic Rules and Errors for Segment Editor

You can use three types of match logic in creating your rules and rule sets for segments. These match logic types are:

1. All returns profiles that match all rules or rule sets.
2. Any returns profiles that match any of the rules or rule sets.
3. Advanced allows you to customize your rules and rule sets, by mixing and pairing rules and rule sets.
![](/assets/image2021-5-26_10-56-57.f316b23bd54c3e2435523baf3f9642af2083e0adf7c578db9e76cc6440cb4f37.cf3845cb.png)


Learn more about this topic:

* [Match Logic for Rules and Rule Sets](#match-logic-for-rules-and-rule-sets)
* [Match Logic for Rules](#match-logic-for-rules)
* [Advanced Match Logic for Rules Example](#advanced-match-logic-for-rules-example)
* [Match Logic for Rule Sets](#match-logic-for-rule-sets)
* [Advanced Logic Errors](#advanced-logic-errors)
* [Rules](#rules)
* [Rule Sets](#rule-sets)


## Match Logic for Rules and Rule Sets

There are some match logic rules that must be adhered to for both rules and rule sets.

### Match Logic for Rules

* All and Any allows any number of rules.
* Advanced match logic allows up to 26 rules to be included.
* Rules are always referred to in letter format (i.e. A, B, C).


| Match logic type | Description | Max. Rules |
|  --- | --- | --- |
| all | includes profiles that match all rules | No limit |
| any | includes profiles that match any rules | No limit |
| advanced | includes profiles that match custom logic i.e. (A and B) or (C and D) | Max. 26 |


If you use match logic ANY with Behavior Activation, see [Match Logic ANY Example with NULL value](/products/customer-data-platform/audience-studio/segment/rule-operator/match-logic-any-advanced-example).

### Advanced Match Logic for Rules Example

![](/assets/image2021-5-26_16-31-8.d06669fbe61599add5fcab643d667e3124d902ab18c7214606a14bb79c3486bd.cf3845cb.png)

### Match Logic for Rule Sets

* All and Any allows any number of rule sets.
* Advanced match logic allows up to 9 rule sets to be included.
* Rule sets are always referred to in number format (i.e. 1, 2, 3)


| Match logic type | Description | Max. Rule Sets |
|  --- | --- | --- |
| all | includes profiles that match all rule sets | No limit |
| any | includes profiles that match any rule sets | No limit |
| advanced | includes profiles that match custom logic i.e. (1 and 2) or (3 and 4) | Max. 9 |


#### Advanced Match Logic for Rule Sets Example

![](/assets/image2021-5-26_16-29-18.a95cc4d0b0d6fd988bd65772f82edf3ce67d5e113605d5b7d7447ac827e63cb4.cf3845cb.png)

## Advanced Logic Errors

Advanced logic customization can result in logic errors if the match logic for rules and rule sets are not followed.

### **Rules**

| Error Message Displayed | Error Example | Match logic error |
|  --- | --- | --- |
| Error 1: Too few rules referenced |  |  |
| A and B |  |  |
| (but there are rules A, B, and C) | There are 3 rules but only 2 are referenced. |  |
| Error 2: Referenced rule does not exist | (1 and 2) and 3 |  |
| Rules are supposed to be in letter format. |  |  |
| Error 3: Invalid format |  |  |


* A and (B or C
* A)and (B
* 1 and 2 and 3
* Weirdsyntax23
* One and two or three


| Format is incorrect.
Error 4: Max rules for advanced logic is 26 (to letter Z) Learn more| A and B and … and Z and AA| There are 27 rules, but the max allowed is 26 for advanced logic.

### Rule Sets

| Error Message Displayed | Error Example | Match logic error |
|  --- | --- | --- |
| Error 1: Too few rule sets referenced | 1 and 2 |  |
| (but there are rule sets 1, 2, and 3) | There are 3 rule sets but only 2 are referenced. |  |
| Error 2: Referenced rule sets does not exist | (1 and 2) or (3 and 4)(but there are rule sets 1, 2, and 3) | Rule set 4 doesn't exist |
| Error 2: Referenced rule set does not exist | (A and B) or C |  |
| Supposed to be numbers in rule sets | Rule sets are supposed to be in number format. |  |
| Error 3: Invalid format Learn more |  |  |


* 1 and (2 or 3
* 1 )and (2
* -1 and 2 and 3
* Weirdsyntax23
* One and two or three


| Format is incorrect.
Error 4: Max rule sets for advanced logic is 9| 1 and 2 and 3 and 4 and 5 and … and 9 and 10| There are 10 rules, but the max allowed is 9 for advanced logic.