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.
Rule: All Employees must work at least four weekend shifts in a six-week scheduling period.
Date:
'All Shifts' - Contains all shifts by employee and date
'Dates' - Contains all dates and what scheduling period they occur in
'Employees' - Contains all Employees
Data Model:
I have created this simple DAX measure that calculates the total number of weekend shifts in the 'All Shifts' table:
# of Weekend Shifts = CALCULATE(COUNTROWS('All Shifts'), 'All Shifts'[is weekend?] = 1)
I need to calculate the percentage of employees who are meeting their requirement by scheduling period. I have come up with a pseudo-code algorithm that I believe would accomplish this, but I am having trouble translating this to DAX.
Pseudo-Code Algorithm:
For each scheduling period:
EmpsMeetingReq = 0
TotalEmps = DISTINCTCOUNT(Employees with Shifts in this Period)
For each employee:
If [# of Weekend Shifts] >= 4:
Then: EmpsMeetingReqs += 1
Else: EmpsMeetingReqs += 0
% Meeting Req = EmpsMeetingReq/TotalEmps
Any help with this would be greatly appreciated.
Thank you,
-Jacob
UPDATE: I have another DAX measure that calculates the number of weekend shifts per employee.
Solved! Go to Solution.
I was able to accomplish this by creating a DAX table using the following:
I was able to accomplish this by creating a DAX table using the following:
Hi @jcecil2 ,
You could use MAXX() function and use [# of Weekend Shifts] >= 4 as the filter to calculate EmpsMeetingReqs.
Then use DISTINCTCOUNT() and use [EmpsMeetingReqs]=0 as the filter to calculate TotalEmps.
Hi @v-eachen-msft,
Thank you for your response. Although, I am a little confused as to why I would use [EmpsMeetingReqs] = 0 as the filter for the DISTINCTCOUNT(). I would think that I am taking a DISTINCTCOUNT() of the Employee ID rather than the count of employees meeting the requirement.
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 |
---|---|
106 | |
94 | |
75 | |
62 | |
50 |
User | Count |
---|---|
147 | |
106 | |
104 | |
87 | |
61 |