# Filter Logic Simplification Help

Is there a way to simplify the below filter logic as it exceeds what is allowed character wise in SalesForce? I tried (1 AND 2 AND 6 AND 7 AND (5 AND 9 AND 3 OR 4)) OR (1 AND 2 AND 3 AND 8 AND 10) but get the following error "Your filter is missing right operand to AND or OR".

What I'm trying to simplify:

(1 AND 2 AND 5 AND 6 AND 7 AND 9 AND 3) OR (1 AND 2 AND 4 AND 6 AND 7) OR (1 AND 2 AND 3 AND 8 AND 10)

Appreciate the help!

• Welcome to SFSE! please see How to Ask on getting the most from the Community. I'd create formula fields on the object to represent all or part of each `(...)` expression. You can also factor out the `1 and 2` which will save you a few chars Mar 10, 2022 at 23:10
• To fix the immediate error, you're missing a left parenthesis for the `3 OR 4` section. Mar 10, 2022 at 23:35

The rule for parentheses is that every operator within a group must be AND or OR. `(5 AND 9 AND 3 OR 4)` violates this rule. I ended up reordering the original filter and spaced out the values to come up with:

``````(1 AND 2 AND 3 AND       5 AND 6 AND 7 AND       9       ) OR
(1 AND 2 AND       4 AND       6 AND 7                   ) OR
(1 AND 2 AND 3 AND                         8 AND       10)
``````

From there, I could see the common groups [1, 2], [3, 5, 9], [3, 8, 10], [4], and [6, 7].

After some more reordering, I ended up with the following:

``````1 AND 2 AND ((3 AND 8 AND 10) OR (((3 AND 5 AND 9) OR 4) AND 6 AND 7))
``````

I'm pretty sure this is correct, but you'll want to verify this for yourself on paper.