Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Running balance (difference) by groups

I'm trying to calculate running balance for quantity on hand after usage. My sample table looks like this. Any idea on what I need to do to get the expected value? Index 1 Index 2 Component S...
  • lbendlin's avatar
    1 year ago

    Why is On hand repeated?  Shouldn't that be only listed for the first date?

     

     

    Measure:

    Running Balance = 
    var c = SELECTEDVALUE('Table'[Component])
    var i = SELECTEDVALUE('Table'[Index 2])
    var b = filter(ALLSELECTED('Table'),[Component]=c && [Index 2]<=i)
    return maxx(b,[On hand])-sumx(b,[Qty required])