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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
EMassicot
Frequent Visitor

Hours used and hours remaining.

Is there a way to calulate two different measures, one for hours used and one for hours remaing? All users start of with 40 hours remaining. The difference between end date and start date represents the hours used.

 

User IDStart DateEnd Date
1119/01/2022 9:00:00 AM9/01/2022 5:00:00 PM
1129/05/2022 8:00:00 AM9/05/2022 4:00:00 PM
1129/06/2022 8:00:00 AM9/06/2022 4:00:00 PM
1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @EMassicot ,

 

Approve with @Gianluca88 , You can use Datediff().

Please try:

Hours used =
VAR _a =
    ADDCOLUMNS (
        FILTER (
            ALL ( 'Table' ),
            [User ID] = MAX ( 'Table'[User ID] )
                && [End Date] <= MAX ( 'Table'[End Date] )
        ),
        "Hours used", DATEDIFF ( [Start Date], [End Date], HOUR )
    )
RETURN
    SUMX ( _a, [Hours used] )

Hours remaining = 40-[Hours used]

Final output:

vjianbolimsft_0-1666594843966.png

Best Regards,

Jianbo Li

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

2 REPLIES 2
v-jianboli-msft
Community Support
Community Support

Hi @EMassicot ,

 

Approve with @Gianluca88 , You can use Datediff().

Please try:

Hours used =
VAR _a =
    ADDCOLUMNS (
        FILTER (
            ALL ( 'Table' ),
            [User ID] = MAX ( 'Table'[User ID] )
                && [End Date] <= MAX ( 'Table'[End Date] )
        ),
        "Hours used", DATEDIFF ( [Start Date], [End Date], HOUR )
    )
RETURN
    SUMX ( _a, [Hours used] )

Hours remaining = 40-[Hours used]

Final output:

vjianbolimsft_0-1666594843966.png

Best Regards,

Jianbo Li

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

Gianluca88
Resolver I
Resolver I

HI @EMassicot ,

 

if you used something like that DATEDIFF function (DAX) - DAX | Microsoft Learn?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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