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
Anonymous
Not applicable

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 1Index 2ComponentStart DateOn handQty requiredRunning Balance (expected value)
11A1/1/20241028
22A1/2/20241026
31B1/1/2024514
42B1/2/2024513
51C1/1/202415114
62C1/2/202415113
71D1/1/20241028
81E1/1/2024514
92E1/2/2024513
103E1/3/2024512
1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

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

 

lbendlin_0-1729632233827.png

 

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])

View solution in original post

2 REPLIES 2
Kedar_Pande
Super User
Super User

Running Balance =
CALCULATE(
MAX(SampleTable[On hand]) - SUMX(
FILTER(
SampleTable,
SampleTable[Component] = EARLIER(SampleTable[Component]) &&
SampleTable[Start Date] <= EARLIER(SampleTable[Start Date])
),
SampleTable[Qty required]
)
)

lbendlin
Super User
Super User

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

 

lbendlin_0-1729632233827.png

 

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])

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.