Tableau计算字段组合和重命名两个数据源

时间:2016-07-11 16:26:13

标签: tableau

我目前在Tableau中进行了以下计算:

IF CONTAINS(ATTR([Unix].[Environment]), 'PROD') THEN 'PROD'
ELSEIF CONTAINS(ATTR([Unix].[Environment]), 'QA') THEN 'QA'
ELSEIF CONTAINS(ATTR([Unix].[Environment]), 'STAGING') THEN 'STAGING'
ELSEIF CONTAINS(ATTR([Unix].[Environment]), 'UAT') THEN 'UAT'
ELSEIF CONTAINS(ATTR([Unix].[Environment]), 'INFRA') THEN 'INFRA'
ELSEIF CONTAINS(ATTR([Unix].[Environment]), 'DEV') THEN 'DEV'
ELSEIF CONTAINS(ATTR([Unix].[Environment]), 'DRP') THEN 'DRP'
ELSEIF CONTAINS(ATTR([Unix].[Environment]), NULL) THEN 'OTHERS'
ELSE 'OTHERS'
END

我有另一个名为Windows的数据源与Environment具有相同的字段,但它被称为ServerEnvironment。此计算字段的用途是用于组合要用于列的Environment和ServerEnvironment字段。但是,我不知道如何检查Unix和Windows中的值。我尝试了以下,但无济于事:

IF CONTAINS(ATTR([Unix].[Environment]), 'PROD') 
OR CONTAINS(ATTR([Windows].[ServerEnvironment]), 'PROD')
THEN 'Prod'
.
.
.

我如何在Unix和Windows中组合检查?最终目标是,例如,Unix具有值“PROD”并且Windows具有值“PROD”,因此使用计算字段,这将创建列“Prod”,并且类似于其他值。

1 个答案:

答案 0 :(得分:1)

The only way to combine both data sources in your example is to either join them in the data source connection window or do data blending when connected to each separately. Either way, they must have some key field that you could join the two on.

Or you could also UNION the data outside of Tableau then connected to that single source. Without more information, I cannot recommend anything more specific.