KNOWLEDGE BASE

Creating Conditional Aggregations


Published: 21 Feb 2014
Last Modified Date: 25 Aug 2016

Question

How to create a calculated field that conditionally aggregates a measure.

Environment

Tableau Desktop

Answer

  1. Select Analysis > Create calculated field....
  2. In the Formula box, type in a formula that uses an IF statement to define a condition. For example:
    IF [Region] = 'South' THEN [Sales] END
  3. Wrap that statement inside of an aggregation. For example:
    SUM(IF [Region] = 'South' THEN [Sales] END)
  4. Click OK.

Additional Information

Alternate Example:
WINDOW_SUM(IF ATTR([Region]) = 'South' THEN SUM([Sales]) END)
Did this article resolve the issue?