KNOWLEDGE BASE

Line Graph Appears Broken When Using a Discrete IF Statement on Rows


Published: 01 Jun 2017
Last Modified Date: 02 Jun 2017

Issue

When using an IF statement as a discrete measure on rows, then a line graph is broken up. 

Environment

Tableau Desktop

Resolution

Wrap the IF statement in a FIXED expression. For example, the following calculation:
IF [Region] = "Central"
THEN [Sales]
END

Could become:
{ FIXED [Category] : SUM(
IF [Region] = "Central"
THEN [Sales]
END
) }

Cause

Technically an IF statement will return at least two values per each partition in the view: the value where the condition is true and the value where the condition is false. These two values are used as bins when the measure is converted into a discrete value because discrete values are used to partition the view.

The FIXED expression will return the same result for every record in the underlying data at the specified level. In the above example, Tableau Desktop will add up all of the sales when [Region] = "Central" + NULL and return that same number for every record within each [Category].
Did this article resolve the issue?