Forum Discussion

AgataJ's avatar
AgataJ
Icon for Helper II rankHelper II
1 year ago
Solved

Subtracting Running Total from first available value in a table

Good morning, I am working on such calculations: I have a column with Hours and Hours Used. For Hours used I need to calculate Running Total, what I have a DAX for it no problem. My problem starts...
  • speedramps's avatar
    1 year ago

    Try this

     

    Answer = 
    
    // get first date
    var myfirstdate = 
    CALCULATE(
        MIN(yourdata[Date]),
        ALl(yourdata)
    )
    
    // get hours for first date
    var myfirstvalue =
    CALCULATE(
    SUM(yourdata[Hours]),
    ALL(yourdata),
    yourdata[Date] <= myfirstdate)
    
    // get date for current row in visual
    var mydate = SELECTEDVALUE(yourdata[Date])
    
    // get running total for row
    var runningtotal =
    CALCULATE(
    SUM(yourdata[Hours used]),
    ALL(yourdata),
    yourdata[Date] <= mydate)
    
    RETURN
    // deduct running toral from first value
    myfirstvalue - runningtotal
    

     

     

    Please click the [accept solution] and thumbs up buttons. Thank you