WOPR
WOPR

Reputation: 5393

Conditional sum in Tableau

I am just starting out with Tableau and have a question.

I have a star schema data warehouse with a fact table containing an "Amount", joined to a dimension containing "Event types"

Two event Types are "Settled" and "Cancelled"

I want to create a calculated measure in Tableau "Net Amount" which is the difference between the sum of Settled and Cancelled.

How do I do that?

I tried

SUM(IIF(Event_type_name = "Settled",Amount,0))-SUM(IIF(Event_type_name = "Cancelled",Amount,0))

but it returns a blank string

Upvotes: 0

Views: 28397

Answers (1)

WOPR
WOPR

Reputation: 5393

After experimentation (and asking Tableau support), it turns out my formula was "correct" but was returning blank because of null's in the amount column.

So I needed to use the ZN function to convert nulls to zero's in the feed.

Upvotes: 4

Related Questions