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

View all the Fabric Data Days sessions on demand. View schedule

Reply
HALEYSTODDARD
Frequent Visitor

Cumulate prior hour's remaining volume and add to next hour's volume

Hi!

 

I'm very new to Power Bi, but I'm hoping to take some suggestions on how to go about this. 

 

Essentially I’m trying to create a custom column to essentially calculate the previous hour’s remaining qty + next  hour’s allocated qty to get a snapshot of the total volume for each hour, but I can’t figure out the formula. 

 

HALEYSTODDARD_1-1656624213068.png

 

 

So for example, the day starts at midnight (12:00 AM, hour 0) and I have 598 units drop but only picked 29, I need my 1:00 AM new total to be 569 remaining from 12:00 AM + the additional 335 units that were allocated at 1 am which would 904 units total. Then we picked 351 between 1-2am, so for 2am it would take the remaining 553 (904-351 picks) + the 285 that are allocated at 2am and so on and so forth. 

 

Any tips on how to go about this? 

 

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You could try creating a column like

Running Total =
VAR currentDate = 'Table'[DATE_REF]
VAR currentHour = 'Table'[Hour_ref]
VAR totalAllocated =
    CALCULATE (
        SUM ( 'Table'[Cart Allocated] ),
        ALLEXCEPT ( 'Table', 'Table'[DATE_REF] ),
        'Table'[Hour_ref] <= currentHour
    )
VAR totalPicked =
    CALCULATE (
        SUM ( 'Table'[Cart Picks] ),
        ALLEXCEPT ( 'Table', 'Table'[DATE_REF] ),
        'Table'[Hour_ref] < currentHour
    )
RETURN
    totalAllocated - totalPicked

View solution in original post

2 REPLIES 2
johnt75
Super User
Super User

You could try creating a column like

Running Total =
VAR currentDate = 'Table'[DATE_REF]
VAR currentHour = 'Table'[Hour_ref]
VAR totalAllocated =
    CALCULATE (
        SUM ( 'Table'[Cart Allocated] ),
        ALLEXCEPT ( 'Table', 'Table'[DATE_REF] ),
        'Table'[Hour_ref] <= currentHour
    )
VAR totalPicked =
    CALCULATE (
        SUM ( 'Table'[Cart Picks] ),
        ALLEXCEPT ( 'Table', 'Table'[DATE_REF] ),
        'Table'[Hour_ref] < currentHour
    )
RETURN
    totalAllocated - totalPicked

that worked perfectly! The only thing I had to change was in the VAR totalPicked the "<" sign to "<=" 

Thanks so much!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.