# Tableau AND Function

The Tableau AND is one of the Logical functions that will perform the logical conjunction between two or more expressions. The AND function will return True if both expressions are evaluated to True. This article shows how to use this Tableau Logical AND function to evaluate multiple expressions within the IF ElSE or IIF statements with examples.

The syntax of the Tableau Logical AND function is as shown below.

`<expression1> AND <expression2>`

The Tableau AND function will return the Boolean True or False. The logical table behind this

## Tableau Logical AND function Examples

To demonstrate this AND function, drag and drop the Category hierarchy and expand to Sub-category level. Next, double-click the Quantity, Sales, Discount, and Profit Measures to add them to the text.

We must create a calculated field to use this Tableau logical AND function. To do this, right-click the Measures shelf empty space to select the Create Calculated Field.. option. It will open the following window to write an expression. Please refer to the Logical Methods and other Function articles in Tableau.

First, rename the calculated field as the Review. In this example, we will find the Sub-Categories with Negative Profits; the expression is as shown below.

`SUM([Profit]) < 0 AND SUM([Quantity]) > 0`

Let me add that calculated field to the table Rows’ shelf to see whether it is true or false. Add the Review field to the Color Shelf to quickly identify the Negative Profits Sub-Categories.

Click the down arrow beside the Review field and choose the Edit Calculated Field option to open the below window. Next, write the below expression and click the Apply button to see the change.

`SUM([Profit]) > 10000 AND SUM([Quantity]) < 4000`

### Evaluate Three expressions

You can use the AND function in Tableau to evaluate two or more functions. To prove the same, we used three expressions: The sum of profit less than 8000, quantity greater than 500, and discount less than 50.

`SUM([Profit]) < 8000 AND SUM([Quantity]) > 500 AND SUM([Discount]) < 50`

### Tableau Logical AND function in If Else Statement

If you observe the above examples, the AND function returns Boolean True or False. However, this approach will only suit the real-time application if we don’t need more meaningful labels. We must use the If else or Elif statements with meaningful messages to achieve this.

The below example returns Good if the sum of Profit is greater than 10000, the Quantity is greater than 1000, and the Discount is less than or equal to 138. Otherwise, it returns Bad.

`IF(SUM([Profit]) > 10000 AND SUM([Quantity]) > 1000AND SUM([Discount]) <= 138) THEN 'Good'ELSE 'Bad'END`

It is another example where we used the ELSEIF statement to return three different messages based on multiple statements, and each statement is a combination of multiple expressions.

`IF( SUM([Sales]) > 2500 AND SUM([Profit]) < 0) THEN 'Bad' ELSEIF (SUM([Sales]) > 25000 AND SUM([Profit]) > 10000) THEN 'Average'ELSE 'Good'END`

### Tableau Logical AND function in IIF Statement

You can also use this logical AND function in the combination or within the IIF condition to return two messages. If both the expressions return True, return True message (Profit). Otherwise, it returns the False message (Loss).

`IIF((SUM([Profit]) < 0 AND SUM([Quantity]) > 0), 'Profit', 'Loss')`