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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
gandharv
Frequent Visitor

Calculate Running Total in DAX with filter on Date, Time, and Categories

Hi Guys, 

Please, I need urgent help with the DAX function to calculate column H in the below dummy data table. I have mentioned the manual calculation in the Excel table for a better understanding of the ask! 

Important to consider :

The Formula should consider Column A, B, C, and D as unique for each row, since as you can see that column H is calculated based on value of a column G in the current row + value of column H in the earlier row (within same model_run, area, date, but earlier time stamp). 

 

gandharv_0-1704289068229.png

 

1 ACCEPTED SOLUTION
Dangar332
Super User
Super User

Hi, @gandharv 



try below

but cross check it before move  ahead

 

Column = 
var a =
    FILTER('Table (2)',
           'Table (2)'[Model_Run]=EARLIER('Table (2)'[Model_Run]) &&
           'Table (2)'[Area] = EARLIER('Table (2)'[Area]) &&
           'Table (2)'[Date] = EARLIER('Table (2)'[Date]) &&
           'Table (2)'[Time]<= EARLIER('Table (2)'[Time])
    )
var b = MINX('Table (2)','Table (2)'[Time])
var d = MINX(FILTER('Table (2)','Table (2)'[Time]=b),'Table (2)'[Price - Cost (Value)])
var c = SUMX(a,'Table (2)'[Price - Cost (Value)])-d
return
IF(c<0,0,c)

 

 

Dangar332_0-1704303566328.png

 

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

View solution in original post

1 REPLY 1
Dangar332
Super User
Super User

Hi, @gandharv 



try below

but cross check it before move  ahead

 

Column = 
var a =
    FILTER('Table (2)',
           'Table (2)'[Model_Run]=EARLIER('Table (2)'[Model_Run]) &&
           'Table (2)'[Area] = EARLIER('Table (2)'[Area]) &&
           'Table (2)'[Date] = EARLIER('Table (2)'[Date]) &&
           'Table (2)'[Time]<= EARLIER('Table (2)'[Time])
    )
var b = MINX('Table (2)','Table (2)'[Time])
var d = MINX(FILTER('Table (2)','Table (2)'[Time]=b),'Table (2)'[Price - Cost (Value)])
var c = SUMX(a,'Table (2)'[Price - Cost (Value)])-d
return
IF(c<0,0,c)

 

 

Dangar332_0-1704303566328.png

 

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

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.