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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
bd27
Frequent Visitor

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
May PBI 25 Carousel

Power BI Monthly Update - May 2025

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

May 2025 Monthly Update

Fabric Community Update - May 2025

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