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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Reddyp
Helper I
Helper I

Inventory aging calculation_DAX

I need to do this inventory calculation for individual branch (Example: if stock sold in branch 1 then the count of sold should deduct from Branch 1)

Example: I have received stock to B ranch 1 on 1st, 2nd, and 3rd and the stock is 10 shirts per day and total stock is 30 now 
and on 4th 15 shirts sold 

desired result: the sold count in Branch 1 should deduct fromn first in date in branch 1(the count sold is 15 on 4th so 10 should be decuted from 1st date and 5 shoud be deducted on 2nd)
and in the same way when 7 shirts sold on 5th date then 5 deducted from 2nd date (remaining in 2nd date) and 2 should deduct from 3rd date

Note: Calculation should be done based on Branch

Can you please helpme with the DAX code
I have already received response from @Greg_Deckler for my previous question in calculating stock in and stock out for one branch (https://community.powerbi.com/t5/Desktop/Inventory-stock/td-p/2431824)
Request: But now I have different branches in my data and I need help in modifing DAX code. 
Example: 

Date

Branch

New Stock

Stock out

Result

01-01-2022

Branch 1

10

 

0

02-01-2022

Branch 1

10

 

0

03-01-2022

Branch 1

10

 

8

04-01-2022

Branch 1

 

15

 

05-01-2022

Branch 1

 

7

 

06-01-2022

Branch 2

10

 

0

07-01-2022

Branch 2

10

 

5

08-01-2022

Branch 2

10

 

10

09-01-2022

Branch 2

 

15

 

10-01-2022

Branch 3

10

 

0

11-01-2022

Branch 3

 

10

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User
1 REPLY 1
tamerj1
Super User
Super User

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.