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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
AlexBA
New Member

How to calculate project hours based on parent/Child relationship

Morning, 

 

I'm a new user to Power BI and have spent the morning trying to figure out how to calculate the total hours for the "parent" based on the hours of the "children".  I know the hours for each child, but need to sum them together to get the hours for the parent.  I could use some help. 

 

Any thoughts, suggestions, links, or examples are truly appreciated. 

 

Here is a highlight of the data provided. 

AlexBA_3-1657295669318.png

 

 

Thanks, Alex 

 

1 ACCEPTED SOLUTION

Hi @AlexBA ,

 

Please try this code:

Column =
CALCULATE (
    SUM ( 'Table'[Child Estimated Hours] ),
    FILTER (
        'Table',
        [Parent Work Item Id] = EARLIER ( 'Table'[Parent Work Item Id] )
    )
)

 

Result:

 

vchenwuzmsft_0-1657691338709.png

 

Best Regards

Community Support Team _ chenwu zhu

 

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

 

View solution in original post

3 REPLIES 3
v-chenwuz-msft
Community Support
Community Support

Hi @AlexBA ,

 

In the table visual, power bi will calculate the hours automatically when you drag it to the values of its Values. O you can use the following measure to sum them.

 

Measure = SUM('Table'[Child Estimated Hours])

 

Result:

vchenwuzmsft_0-1657533485143.gif

 

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

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

Morning and Thank you. 

 

I'm looking to do the breakdown within a table, not a visual, unfortunately.  On the breakdown, I need to be able to filter/sum the hours by the parent. I'll need to create a column that's the total of each Parent ID hours. 

 

For example, Parent ID 25240 should have a total of 190 hours since its children are 25241 (38 Hours) and 25245 (152 Hours). 

 

Maybe that question now is how to add a parent filter to your measure? 

 

Thanks, 

Alex 

Hi @AlexBA ,

 

Please try this code:

Column =
CALCULATE (
    SUM ( 'Table'[Child Estimated Hours] ),
    FILTER (
        'Table',
        [Parent Work Item Id] = EARLIER ( 'Table'[Parent Work Item Id] )
    )
)

 

Result:

 

vchenwuzmsft_0-1657691338709.png

 

Best Regards

Community Support Team _ chenwu zhu

 

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

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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