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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
WTAS80486
Helper IV
Helper IV

Calculate cumulative Total hours based on ID and date

Hi,

 

I am trying to calculate cumulative of total hours based on ID and Date

 

Cumulative Run Hours = CALCULATE( SUM('Table'[Hours]),
FILTER(
ALL('Table'[ ID]),
'Table'[Date] <=MAX('Table'[Date)]
)
))
 
Nothing seems to work. ALL, ALLEXCEPT, EARLIER

 

IDDateHoursCumulative
A11/9/2021   33
A12/1/2021   69
A1/2/2022   918
B2/3/2022   22
B3/4/2022   46
B4/5/2022   816
C5/3/2022   33
C6/2/202247
C7/1/2022414

Can someone please help.

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @WTAS80486 ,

According to your description, here's my solution.

Create a Date table.

Date = CALENDAR(DATE(2021,1,1),DATE(2022,12,31))

Create relationship between the two tables with the Date column. Then create a measure.

Cumulative =
CALCULATE (
    SUM ( 'Table'[Hours] ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[ID] = MAX ( 'Table'[ID] )
            && 'Table'[Date] <= MAX ( 'Date'[Date] )
    )
)

Get the result.

vkalyjmsft_0-1660725651220.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

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

6 REPLIES 6
v-yanjiang-msft
Community Support
Community Support

Hi @WTAS80486 ,

According to your description, here's my solution.

Create a Date table.

Date = CALENDAR(DATE(2021,1,1),DATE(2022,12,31))

Create relationship between the two tables with the Date column. Then create a measure.

Cumulative =
CALCULATE (
    SUM ( 'Table'[Hours] ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[ID] = MAX ( 'Table'[ID] )
            && 'Table'[Date] <= MAX ( 'Date'[Date] )
    )
)

Get the result.

vkalyjmsft_0-1660725651220.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

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

 

WTAS80486
Helper IV
Helper IV

I am trying to solve the same thing on measure from another table and get cumulative counts of failures based on month in another column of another table. But getting error

Hi @WTAS80486 ,

 

So what are the error you encountered? Do you have sample data from another table or a PBIX file (without private data)?

 

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

Best regards.

Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Untitled.png

 

Cumulative Run Hours =
IF (
    HASONEVALUE ( 'Table'[ID] ),
    CALCULATE (
        SUM ( 'Table'[Hours] ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[ID] ),
            'Table'[Date] <= MAX ( 'Table'[Date] )
        )
    )
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Thanks for the reply!

 

This dosents seem to work on my data.

 

I used this:

 

Culmulative hours = CALCULATE (
                SUM('Table'[Hours]),
                FILTER (
                    ALL ( 'Table'),
                    'Table'[ ID] = EARLIER ( 'Table'[ ID] )
                        && 'Table'[Date]<= EARLIER ('Table'[Date])
                )
            )
WTAS80486
Helper IV
Helper IV

I solved this by:

 

Culmulative hours = CALCULATE (
                SUM('Table'[Hours]),
                FILTER (
                    ALL ( 'Table'),
                    'Table'[ ID] = EARLIER ( 'Table'[ ID] )
                        && 'Table'[Date]<= EARLIER ('Table'[Date])
                )
            )

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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