简体   繁体   English

Tableau - 计算最大数量

[英]Tableau - Count the maximum number

I have a dataset of employees by Segment, I was trying to find by each Segment what is the maximum sales % and how many employees achieved it.我有一个按部门划分的员工数据集,我试图按每个部门查找最大销售额百分比是多少以及有多少员工实现了这一目标。

First, I have created a calculated field, Target Achievement = Actual Sales / Target Sales, which works fine.首先,我创建了一个计算字段,目标成就 = 实际销售额 / 目标销售额,它工作正常。 Next, I would like to find what is the maximum Target Achievement and how many employees achieved in a filtered Segment?接下来,我想找出最大目标成就是多少以及在过滤的细分中实现了多少员工?

I have tried using WINDOWS_MAX(), which returned the correct maximum Target Achievement, but I am not able to count the employees who have achieved the maximum.我尝试使用 WINDOWS_MAX(),它返回了正确的最大目标成就,但我无法计算达到最大值的员工。

Have you tried using the WINDOW_MAX in another calculation?您是否尝试在另一个计算中使用 WINDOW_MAX? Something like:就像是:

IF [TargetAchievement] = WINDOW_MAX([TargetAchievement]) THEN [EmployeeID] END

If that works you can count / countd that field.如果可行,您可以计算/计算该字段。

An alternative, which may be more effective in this case, would be to use LOD calculations.在这种情况下可能更有效的替代方法是使用 LOD 计算。 Something along the lines of this: https://tarsolutions.co.uk/blog/create-fixed-bins-from-a-measure-in-tableau/类似这样的东西: https://tarsolutions.co.uk/blog/create-fixed-bins-from-a-measure-in-tableau/

For your example the FIXED may need applying within the [TargetAchievement] field;对于您的示例,FIXED 可能需要在 [TargetAchievement] 字段中应用; "fixing" the Actual and Target Sales. “修复”实际和目标销售额。

Create a binary calculated field 'achieved_max' as follows:创建一个二进制计算字段“achieved_max”,如下所示:

IF [Target Achievement] >= WINDOW_MAX([Target Achievement])
THEN 1
ELSE 0
END

After that try:之后尝试:

  1. Drag this new 'achieved_max' to Columns tab and drag Number of Records from Measures to Rows Tab.将这个新的“achieved_max”拖到“列”选项卡,然后将“记录数”从“度量”选项卡拖到“行”选项卡。
  2. Filter by Segment按段过滤

Number of Records with 'achieved_max' as 1 should be the the number employees who achieved the max target in the chosen segment. 'achieved_max' 为 1 的记录数应该是在所选细分中实现最大目标的员工人数。

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

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