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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.