Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello,
I am working on building Turnover functionality and need to know headcount at a certain point in time. The transactional data I am using looks something like this:
Employee ID | Event Date | Status |
1 | 1/1/20 | Active |
2 | 1/1/20 | Active |
3 | 2/1/20 | Active |
1 | 3/1/20 | Terminated |
2 | 3/1/20 | Active |
3 | 3/1/20 | Active |
1 | 4/1/20 | Active |
Based on the transactional data above I would expect to see end of the month headcount for each month to be: Jan = 2, Feb = 3, Mar = 2, Apr = 3.
Employees will have multiple transactions for their Employee ID.
Any help is greatly appreciated!
Solved! Go to Solution.
@dupreem -
Measure 14 =
VAR __Date = MAX([Event Date ])
VAR __Active = DISTINCT(SELECTCOLUMNS(FILTER(ALL('Table (14)'),[Event Date ]<=__Date && [Status]="Active"),"ID",[Employee ID ]))
VAR __Term = DISTINCT(SELECTCOLUMNS(FILTER(ALL('Table (14)'),[Event Date ]<=__Date && ([Status]="Terminated" || [Status]="Retiree" || [Status]="Dead")),"ID",[Employee ID ]))
RETURN
COUNTROWS(EXCEPT(__Active, __Term))
@dupreem - See attached PBIX file below sig, Page 14
Measure 14 =
VAR __Date = MAX([Event Date ])
VAR __Active = DISTINCT(SELECTCOLUMNS(FILTER(ALL('Table (14)'),[Event Date ]<=__Date && [Status]="Active"),"ID",[Employee ID ]))
VAR __Term = DISTINCT(SELECTCOLUMNS(FILTER(ALL('Table (14)'),[Event Date ]<=__Date && [Status]="Terminated"),"ID",[Employee ID ]))
RETURN
COUNTROWS(EXCEPT(__Active, __Term))
@Greg_Deckler Thank you so much! If I have multiple "Terminated" statuses (i.e. "Terminated, Retiree), how would I update the Measure?
@dupreem -
Measure 14 =
VAR __Date = MAX([Event Date ])
VAR __Active = DISTINCT(SELECTCOLUMNS(FILTER(ALL('Table (14)'),[Event Date ]<=__Date && [Status]="Active"),"ID",[Employee ID ]))
VAR __Term = DISTINCT(SELECTCOLUMNS(FILTER(ALL('Table (14)'),[Event Date ]<=__Date && ([Status]="Terminated" || [Status]="Retiree" || [Status]="Dead")),"ID",[Employee ID ]))
RETURN
COUNTROWS(EXCEPT(__Active, __Term))
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
99 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
102 | |
87 | |
64 |