返回每个语句都为真的值 Tableau [英] Return values where each statement is true Tableau

查看:32
本文介绍了返回每个语句都为真的值 Tableau的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图返回多个字段可能缺少值的记录.我有以下声明:

I am attempting to return records where multiple fields may be missing values. I have the following statement:

IF ISNULL([Sales Team]) THEN 'Sales Team'
   ELSEIF ISNULL([Portfolio]) THEN 'Portfolio'
   ELSEIF ISNULL([Category Type]) THEN 'Category Type'
   ELSEIF [Datasource] = 'DS1' AND ISNULL([Item Class Dtl]) THEN 'Item Class Dtl'
   ELSEIF ISNULL([Market]) THEN 'Market'
END

如果销售团队和投资组合在单个记录中为 NULL,我想在各自的行下返回销售团队和投资组合的金额.由于 ELSEIF 的性质,当销售团队为 NULL 时不包括投资组合金额.

If Sales Team and Portfolio are NULL in a single record I want to return Sales Team and Portfolio amounts under their respective rows. Due to the nature of the ELSEIF, Portfolio amounts are excluded when Sales Team is NULL.

我的最终目标是将仪表板中的 10 个工作簿减少到两个.我目前正在单独检查 NULLS 并将结果合并到仪表板中.

My end goal is to take this from 10 workbooks in a dashboard down to two. I am currently making the check for NULLS on a singular basis and combining the results in a dashboard.

从此:

为此:

我可以使用其他 Tableau 函数来实现此目的或以其他方式重写此方法吗?谢谢!

Is there another Tableau function I can use to achieve this or another way to rewrite this? Thanks!

推荐答案

您需要将其分解为单独的计算字段.因此,例如,销售团队计算将如下所示:

You need to break this out into separate calculated fields. So, for example, the Sales Team calc would look like:

IF ISNULL([Sales Team]) THEN 'Sales Team' END

为每个条件创建一个计算字段.然后,您可以从单个记录中获得多个真实"结果.

Create one calculated field for each condition. You can then get multiple "true" results from a single record.

回应更新的问题:

如果销售团队和投资组合在单个记录中为 NULL 我想返回销售团队和投资组合金额

If Sales Team and Portfolio are NULL in a single record I want to return Sales Team and Portfolio amounts

因此,多个计算公式的合并将发生在计算金额的公式中.我目前不知道那个金额公式是什么样的,所以我举一个一般的例子.

So, the consolidation of the multiple calculated formulas would happen in the formula that calculates the amount. I don't currently know what that amount formula looks like, so I will give a general example.

测试 NULL 的公式(我们称之为 Sales Team Check)如下所示:

Formula that tests for NULL (Let's call this Sales Team Check) would look like:

IF ISNULL([Sales Team]) THEN [Sales Team Amount] ELSE 0 END

每个条件都有一个公式.然后,合并公式将如下所示:

You would have a formula for each condition. Then, the consolidating formula would look like:

[Sales Team Check] + [Portfolio Check] + [Category Type Check] + [Datasource Check] + [Market Check]

这里的想法是,当您检查 NULL 字段的记录时,不是返回 Text,而是返回金额,否则返回零.然后将这些检查的结果相加.

The idea here is that instead of returning Text when you check the record for a NULL field, you return the amount, otherwise return zero. Then add up the result of those checks.

这篇关于返回每个语句都为真的值 Tableau的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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