# Formula containing picklist and checkbox returning error - error "Incorrect parameter type for function 'AND()'. Expected Boolean, received Text"

I have created a Formula field that supposes to return the Text value. However I am getting the error

Incorrect parameter type for function 'AND()'. Expected Boolean, received Text.

Based on Priority and Escalated selection this formula should show the value (shown on the right side).

Priority is a picklist field and Escalated is a Checkbox field.

• Priority = High and Escalated = true > P1 - Escalated High
• Priority = High and Escalated = false > P2 - High
• Priority = Medium and Escalated = true > P3 - Escalated Medium
• Priority = Low and Escalated = true > P4 - Escalated Low
• Priority = Medium and Escalated = false > P5 - Medium
• Priority = Low and Escalated = false > P6 - Low
``````IF(
AND(
ISPICKVAL(Priority,  "High"),
IsEscalated,
"True",
"P1 - Escalated High",
(IF(
AND(
ISPICKVAL(Priority, "High"),
IsEscalated,
"False",
"P2 - High",
(IF(
AND(
ISPICKVAL(Priority, "Medium"),
IsEscalated,
"True",
"P3 - Escalated Medium",
(IF(
AND(
ISPICKVAL(Priority, "Medium"),
IsEscalated,
"False",
"P5 - Medium",
(IF(
AND(
ISPICKVAL(Priority, "Low"),
IsEscalated,
"True",
"P4 - Escalated Low",
(IF(
AND(
ISPICKVAL(Priority, "Low"),
IsEscalated,
"False",
"P6 - Low"
)
))
)
))
)
))
)
))
)
))
)
)
``````

The input of `AND` function must be expressions that evaluate to a boolean, e.g. `AND( ISPICKVAL(CustomField__c, "Text"), Quantity > 1)`. It returns a `true` only if every expression evaluates to `true`, so it returns `false` if at least one expression evaluates to `false`.

You got that error because you closed the round bracket of the first `AND` at the very end of the formula, so you're passing text values ("true", "P1 - Escalated High", etc...) to that function.

Due to the same reason even the `IF` functions are incorrect. The signature of `IF` function is `IF(logical_test, value_if_true, value_if_false)`

You should always indent your formula to catch such errors asap.

Anyway you don't need the `AND` function, because you could check first the Priority's value, then have an IF on `IsEscalated`, so if High, Medium and Low are the only values of `Priority` the formula could be:

``````IF( ISPICKVAL(Priority,  "High"),
IF ( IsEscalated, "P1 - Escalated High", "P2 - High"),
IF ( ISPICKVAL(Priority,  "Medium"),
IF ( IsEscalated, "P3 - Escalated Medium", "P5 - Medium"),
IF ( IsEscalated, "P4 - Escalated Low", "P6 - Low")
)
)
``````

In pseudo-code it would be:

``````if (Priority == "High") {
if (IsEscalated) {
return "P1 - Escalated High";
}
return "P2 - High";
} else if (Priority == "Medium") {
if (IsEscalated) {
return "P3 - Escalated Medium";
}
return "P5 - Medium";
} else if (IsEscalated) {
return "P4 - Escalated Low";
}
return "P6 - Low";
``````

By the way, if those are custom fields, they should be `Priority__c` and `IsEscalated__c`.

You can try this way:

``````IF(
AND(
SPICKVAL(Priority, "High"),
IsEscalated
),
"P1 - Escalated High",
IF(
AND(
ISPICKVAL(Priority, "High"),
NOT(IsEscalated)
),
"P2 - High",
IF(
AND(
ISPICKVAL(Priority, "Medium"),
IsEscalated
),
"P3 - Escalated Medium",
IF(
AND(
ISPICKVAL(Priority, "Medium"),
NOT(IsEscalated)
),
"P5 - Medium",
IF(
AND(
ISPICKVAL(Priority, "Low"),
IsEscalated
),
"P4 - Escalated Low",
IF(
AND(
ISPICKVAL(Priority, "Low"),
NOT(IsEscalated)
),
"P6 - Low",
""
)
)
)
)
)
)
``````
• Code dumps aren't very useful as answers. The explanation is just as important as the solution. How is this different from what OP already has? How does it fix the error? Commented Aug 16, 2023 at 23:56