cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Helper IV

## Matrix - How do I get my measure to divide by week instead of day on drilldown?

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.

1 ACCEPTED SOLUTION
Super User

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.

6 REPLIES 6
Helper IV

The way I solved this was to rewrite my sql query so that it did the math in SQL.

Super User

Glad to hear that it is solved.

Super User

Glad to hear that it is solved.

Super User

Try this if it helps ...

1) Add columns to both tables

``Week = "Week " & WEEKNUM(Table_EmpCalendar[Date],2) ``

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:

Helper IV

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 😞

Super User

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.

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

#### Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors