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
alex9999
Helper I
Helper I

Cumulative Total by hour

I've checked most of the forum posts regarding cumulative and running totals but none of them seem to be working with my report. 

 

DateIn/OutTonnage
1/04/2022In345
1/04/2022Out335
10/04/2022In355
11/04/2022In20

 

I currently have a line graph with the date on the X-Axis, and the tonnage on the Y-Axis. I want the tonnage to be running through cumunitavely (in for counting for plus tonnage, out counting for minus tonnage). 

 

For example, 1/04/2022 will read as 10 on Y-Axis (345 - 335).

 

10/04/2022 will read as 365 on Y-Axis (10 + 355)

 

11/04/2022 will read as 385 on Y-Axis (365 + 20)

 

Any help will be appreciated 🙂

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@alex9999 

Please check the attached file:

Fowmy_0-1653308472012.png

 

Running Total = 
VAR __Date = max( Dates[Date])
VAR __InTotal = 
    CALCULATE(
        SUM(Table1[Tonnage]),
        Table1[In/Out] = "IN",
        'Dates'[Date] <= __Date,        
        ALLSELECTED( 'Dates' )        
    )
VAR __OutTotal = 
    CALCULATE(
        SUM(Table1[Tonnage]),
        Table1[In/Out] = "OUT",
        'Dates'[Date] <= __Date,        
        ALLSELECTED( 'Dates' )        
    )
RETURN
   IF( sum(Table1[Tonnage]) <> BLANK(),
       __InTotal - __OutTotal
    )

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

2 REPLIES 2
Fowmy
Super User
Super User

@alex9999 

Please check the attached file:

Fowmy_0-1653308472012.png

 

Running Total = 
VAR __Date = max( Dates[Date])
VAR __InTotal = 
    CALCULATE(
        SUM(Table1[Tonnage]),
        Table1[In/Out] = "IN",
        'Dates'[Date] <= __Date,        
        ALLSELECTED( 'Dates' )        
    )
VAR __OutTotal = 
    CALCULATE(
        SUM(Table1[Tonnage]),
        Table1[In/Out] = "OUT",
        'Dates'[Date] <= __Date,        
        ALLSELECTED( 'Dates' )        
    )
RETURN
   IF( sum(Table1[Tonnage]) <> BLANK(),
       __InTotal - __OutTotal
    )

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Thank you, exactly what I was looking for! Great help 🙂

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.

Top Solution Authors