Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
itsme
Resolver I
Resolver I

SUMX Employee PTO Hours over Multiple Tables

I have a Calendar table, a table that lists holidays and # of PTO hrs on those dates, an employee table, a project assignment table that lists assignment id and employee (employee can have mulitple assignments), and a project forecast table for each assignment with dates and forecast hours. Here's an example of the model:

itsme_0-1660632258681.png

For May and July, PTO hours for each employee working on projects should look like this:

itsme_1-1660632354821.png

You see there are 7 Assignments, but only 6 employees - Robert has 2 different assignments. I need the table to look like this. When PTO hours are summed for July, there should be 48 hours (6 employees times 8 PTO hours). Unfortunately, my SUMX measure is showing 56 hours instead and 80 hours for May and July together when it should be 72 combined:

itsme_2-1660632552593.png

I am using: 

PTO_SUMX = SUMX ( 'Project Forecast', [PTO_SUM] )
where
PTO_SUM = SUM ( Holiday[Hours] )
If I use PTO_SUMX = SUMX ( DISTINCT ( 'Project Forecast'[Employee] ), [PTO_SUM] ) then I get the correct monthly values but incorrect sum for May and July together:
itsme_3-1660632952348.png

 

Can someone please help me? I feel like I'm so close to having this right!

Thank you so much in advance!

1 ACCEPTED SOLUTION

@itsme 

You are right. I didn't know you are slicing by in your report.  Please try

PTO_SUMX =
SUMX (
    VALUES ( 'Calendar'[Month] ),
    CALCULATE ( SUMX ( VALUES ( 'Employee'[Employee] ), [PTO_SUM] ) )
)

View solution in original post

6 REPLIES 6
tamerj1
Super User
Super User

Hi @itsme 
Holiday is filtered only by Calendar table. I think you just need to iterate the Employee table as follows

PTO_SUMX =
SUMX ( VALUES ( 'Employee'[Employee] ), [PTO_SUM] )

This makes sense, but ends up giving me the results below, which is very close. The Month values are correct but the total should be 72, not 96.

itsme_0-1660663375227.png

Here's a breakdown of what your measure is doing on the Assignment Id level. ID's 1 to 4 should be a total of 8, not 16 because they only had 8 PTO hours for May. I need the grand total to sum the PTO for each consultant only once. Robert is on Assignment 1 and 2, and on a line level it should show 8 PTO hours for him on each Assignment, but should only count it once for the grand total, because we will be paying only for 8 hours of PTO even though he's working on 2 assignments.

itsme_1-1660664046684.png

 

@itsme 

You are right. I didn't know you are slicing by in your report.  Please try

PTO_SUMX =
SUMX (
    VALUES ( 'Calendar'[Month] ),
    CALCULATE ( SUMX ( VALUES ( 'Employee'[Employee] ), [PTO_SUM] ) )
)

@tamerj1 This seems to work!! Thank you!

Dhacd
Resolver III
Resolver III

Hi @itsme ,

Is can you try creating a relationship between the project assignment and the holiday table, The project assignment should slice the holiday table. Then this might show correctly.

If this post helps, then please consider accepting it as the solution to help the other members find it more quickly.

Thanks and Regards,
Atma.

Unfortunately, we don't have the holiday table at an employee level. Since all employees on assignments recieve holiday pay, perhaps I need to make that table.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors