Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
I have a matrix visual that shows the percentage of hours that an employee has worked out of their total workable hours for each week. I want to be able to add another field to the column, so that the user can click to drill down and see the projects that contribute to that number. But when I try to do that, the calculation breaks. I would like the percentage shown to be the percentage of hours that employee has worked on that project during that week. But the calculation only divides the number of hours worked into the number of hours available only on the days they worked on the project (not the week). Can someone help me figure out how to have it find the percentage of hours worked out of the whole week?
Here is how the data is organized.
There is a labor detail table that shows the number of hours worked:
And an employee calendar table that shows each employees workable hours by day.
These two tables are related with a concatenated key of Employee+date. The calculation I'm using is simply (SUM(Hours)/Workable Hours). I've tried a few other more complex calculations, but I just can't figure it out.
In the example above, the 4 hours that Todd worked on Project 2 on 1/3/23 would appear as 50% (4/8) instead of 5% (4/20).
I hope this is enough to give a picture of what I'm working with. Thanks for taking the time to read my headache.
Solved! Go to Solution.
Can you share the .pbix file so that we can take a look?
I tried like this
2. Data as
3. In the previous post visualization image, Used "Week" from emp calendar table for the left two matrixes and from labor table for the right matrix.
The way I solved this was to rewrite my sql query so that it did the math in SQL.
Glad to hear that it is solved.
Glad to hear that it is solved.
Try this if it helps ...
1) Add columns to both tables
Week = "Week " & WEEKNUM(Table_EmpCalendar[Date],2)
2) Add measures
Table: EmpCalendar
Sum Emp Calendar Hours = Sum (Table_EmpCalendar[Hours])
Table: Labor
Sum Labor Hours = Sum (Table_Labor[Hours])
Table: EmpCalendar
% by week =
var _selectWeek = SELECTEDVALUE( Table_EmpCalendar[Week] )
VAR _BASELINE_VALUE = CALCULATE([Sum Emp Calendar Hours], Table_EmpCalendar[Week] = _selectWeek )
VAR _MEASURE_VALUE = CALCULATE( [Sum Labor Hours], Table_Labor[Week] = _selectWeek )
RETURN IF ( ISBLANK(_MEASURE_VALUE), BLANK(), _MEASURE_VALUE/ _BASELINE_VALUE )
Format the % calc as percentage with 2 decimals
Output:
Thank you so much for this very thoughtful and detailed solution. I followed it to the tee, but it produced the same result as my previous solution 😞
Can you share the .pbix file so that we can take a look?
I tried like this
2. Data as
3. In the previous post visualization image, Used "Week" from emp calendar table for the left two matrixes and from labor table for the right matrix.