Reputation: 17
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.
Upvotes: 0
Views: 355
Reputation: 438
Create a binary calculated field 'achieved_max' as follows:
IF [Target Achievement] >= WINDOW_MAX([Target Achievement])
THEN 1
ELSE 0
END
After that try:
Number of Records with 'achieved_max' as 1 should be the the number employees who achieved the max target in the chosen segment.
Upvotes: 1
Reputation: 1735
Have you tried using the WINDOW_MAX in another calculation? 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. Something along the lines of this: 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; "fixing" the Actual and Target Sales.
Upvotes: 1