feb
feb

Reputation: 79

Create a new column by picking non-null values from 3 different columns in Tableau

I have outer-joined 3 data sources - Sales, Cost, Price details to make sure I don't miss any rows from either of data sources. A sample of my case looks as below:

enter image description here

As per above image, after outer joining I find Cost and Price info for Brand E but there is no sale of Brand E as a reason Brand column from Sales data appears null against Brand 'E' at both Cost and Price details.

I want to create a new column called 'Brand_New' where all Brand from A to D as in Sales should get populated also Brand 'E' from Cost details and Brand 'E' from Price details should also get populated under 'Brand_New'.

I wrote a logic in Tableau as: IF ([Brand] = 'null') THEN [Brand (cost)] ELSE [Brand (price)] END

But this did not help, could anyone please help me with a logic for this. Please let me know for any further details.

Upvotes: 1

Views: 335

Answers (1)

xkavator
xkavator

Reputation: 386

So, you need a non-null value from [Brand], [Brand(cost)] and [Brand(price)]. You could use something like this for the definition of [Brand_new] calculation:

IFNULL([Brand],IFNULL([Brand(cost)],[Brand(price)]))

Upvotes: 1

Related Questions