What are Logical Calculations in Tableau?

Logical calculations allow you to determine if a certain condition is true or false (Boolean logic). For example, you might want to quickly see if sales for each country you distribute your merchandise to were above or below a certain threshold.

Follow along with the steps below to learn how to create a logical calculation.

  1. In Tableau Desktop, connect to the Sample - Superstore saved data source, which comes with Tableau.
  2. Navigate to a worksheet.
  3. From the Data pane, drag State to the Rows shelf.
  4. From the Data pane, drag Category to the Rows shelf and place it to the right of State.
  5. From the Data pane, drag Sales to the Columns shelf.
  6. Select Analysis > Create Calculated Field.

In the calculation editor that opens, do the following:

  • Name the calculated field, KPI.
  • Enter the following formula:
  • SUM([Profit]) > 0
  • This calculation quickly checks if a member is great than zero. If so, it returns true; if not, it returns false.
  • When finished, click OK.
  • The new calculated field appears under Measures in the Data pane. Just like your other fields, you can use it in on or more visualizations.

From the Data pane, drag KPI to Colour on the Marks card.