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

旧城冷巷雨未停 提交于 2019-12-08 04:32:23

问题


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:

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.


回答1:


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)]))


来源:https://stackoverflow.com/questions/47652152/create-a-new-column-by-picking-non-null-values-from-3-different-columns-in-table

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!