简体   繁体   English

Tableau使用过滤器创建计算字段

[英]Tableau creating calculated field using filter

i have a table in tableau and i wanna create a calculated field based on a filter. 我在tableau中有一张表,我想基于过滤器创建一个计算字段。 Can someone help me in finding the solution for the following logical statement. 有人可以帮我找到以下逻辑陈述的解决方案吗?

I have a table which contains some customers. 我有一张桌子,里面有一些顾客。 It also contains some special customers say 'members'. 它还包含一些特殊的客户,例如“会员”。 Now I wanna show the total amount of billing for members customers and total amount for the remaining ones. 现在,我想显示会员客户的帐单总额以及其余客户的帐单总额。

I have special range for these member customers ID. 对于这些会员客户ID,我有特殊的范围。 Ids lies between 300 and 399, both inclusive. ID位于300到399之间(包括两者)。

Please help. 请帮忙。 Thanks in advance 提前致谢

I assume that the measure you want to sum is the Customer Pay. 我假设您要求和的度量是客户工资。 Then, you can do this in three neat steps. 然后,您可以通过三个简单的步骤完成此操作。

First Step: Create a calculated field called 'Customer Type' 第一步:创建一个名为“客户类型”的计算字段

IF [Customer Code] >= 300 AND [Customer Code] <= 399 THEN 'Member' ELSE 'Normal' END

Second Step: Create a calculated field called 'Member Total Billing Amount' 第二步:创建一个名为“会员总账单金额”的计算字段

SUM(IF [Customer Type] = 'Member' THEN [Customer Pay] END)

Third Step: Create a calculated field called 'Non-member Total Billing Amount' 第三步:创建一个名为“非会员总帐单金额”的计算字段

SUM(IF [Customer Type] = 'Normal' THEN [Customer Pay] END)

You can now drag Member Total Billing Amount and Non-member Total Billing Amount measures into the view as desired. 现在,您可以根据需要将“成员总计帐单金额”和“非成员总计帐单金额”度量拖到视图中。

Note: 注意:

  1. The calculated field called 'Customer Type' will be saved under Dimensions. 计算出的称为“客户类型”的字段将保存在“维度”下。 So, go up there and look for it. 所以,去那里寻找它。

  2. I have only named the calculated fields for illustration purposes. 我仅将计算字段命名为说明目的。 Feel free to change it to what is more intuitive for you. 随时将其更改为更直观的内容。

  3. Another thing to consider, depending on your needs, will be to add Customer Type on the Color Marks card and it will divide Customer Pay into 'Members' and 'Normal'. 根据您的需要,要考虑的另一件事是在“色标”卡上添加“客户类型”,它将“客户工资”分为“会员”和“普通”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM