通过从Tableau中的3个不同列中选择非空值来创建新列 [英] Create a new column by picking non-null values from 3 different columns in Tableau

查看:601
本文介绍了通过从Tableau中的3个不同列中选择非空值来创建新列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我拥有外部连接的3个数据源-销售,成本,价格明细,以确保我不会错过任何一个数据源中的任何行.我的案例示例如下:

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:

如上图所示,在外部加入之后,我找到了品牌E的成本和价格信息,但是没有出售品牌E,这是因为销售"数据中的品牌"列在成本"和价格"细节上都相对于品牌"E"显示为空.

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.

我想创建一个名为"Brand_New"的新列,其中应填充销售中从A到D的所有品牌,还应填充成本"详细信息中的"E"品牌,而来自价格详细信息中的"E"品牌也应填充在"Brand_New"中'.

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'.

我在Tableau中写了一个逻辑: IF([Brand] ='null')THEN [Brand(cost)] ELSE [Brand(price)] END

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.

推荐答案

因此,您需要[Brand],[Brand(cost)]和[Brand(price)]中的非空值. 您可以将以下内容用于[Brand_new]计算的定义:

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

这篇关于通过从Tableau中的3个不同列中选择非空值来创建新列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆