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

View all the Fabric Data Days sessions on demand. View schedule

Reply
rajasekaro
Helper II
Helper II

How to Calculate Stock Aging Using FIFO Method

hi Team,
I’m working on a stock/ inventory aging report in Power BI and need to apply the
FIFO (First-In-First-Out) logic to calculate the age of the remaining stock.
 i tryd but not comming correctly ,it showing stock movement

rajasekaro_0-1760693792550.png

 


How to Calculate Stock Aging Using FIFO Method
table : F_Inventory

ItemDOCIDIN_DOCDATEqtyTRTY
Surgical Mask45014930-01-2024400RCPT
Surgical Mask45016910-03-2024400RCPT
Surgical Mask45019508-08-2024250RCPT
Surgical Mask45023907-06-2024100RCPT
Surgical Mask45030823-07-2025100ISSU
Surgical Mask45031008-09-2024250ISSU
Surgical Mask45031401-01-2025250RCPT
Surgical Mask45033131-05-2024100RCPT
Surgical Mask45040230-01-2024200RCPT
Surgical Mask45041525-04-2024200RCPT
Surgical Mask45042001-03-2024150RCPT
Surgical Mask45044305-05-2025100RCPT
Surgical Mask45055130-01-2025300RCPT
Surgical Mask45058422-02-2024150RCPT
Surgical Mask45058904-02-2024100RCPT
Surgical Mask45059301-02-2024400RCPT
Surgical Mask45060525-04-2024300RCPT
Surgical Mask45062928-01-2024100RCPT
Surgical Mask45063503-07-2024150RCPT
Surgical Mask45089712-04-2024300RCPT
Surgical Mask45092721-05-2024300ISSU
Surgical Mask45094706-05-2025150RCPT
Surgical Mask45096504-04-2024300RCPT
Surgical Mask45097505-03-2024150ISSU
Surgical Mask45099506-06-2025250RCPT
1 ACCEPTED SOLUTION
grazitti_sapna
Super User
Super User

Hi @rajasekaro,

 

Create a measure for running balance for receipts

 

CumulativeReceipts =
CALCULATE(
SUM(F_Inventory[qty]),
FILTER(
F_Inventory,
F_Inventory[Item] = EARLIER(F_Inventory[Item]) &&
F_Inventory[TRTY] = "RCPT" &&
F_Inventory[IN_DOCDATE] <= EARLIER(F_Inventory[IN_DOCDATE])
)
)

 

Dax for running balance for issues

CumulativeIssues =
CALCULATE(
SUM(F_Inventory[qty]),
FILTER(
F_Inventory,
F_Inventory[Item] = EARLIER(F_Inventory[Item]) &&
F_Inventory[TRTY] = "ISSU" &&
F_Inventory[IN_DOCDATE] <= EARLIER(F_Inventory[IN_DOCDATE])
)
)

 

DAX for Remaining stock per receipt

 

RemainingQty =
VAR Receipts = F_Inventory[qty]
VAR Used = CALCULATE(
SUM(F_Inventory[qty]),
FILTER(
F_Inventory,
F_Inventory[Item] = EARLIER(F_Inventory[Item]) &&
F_Inventory[TRTY] = "ISSU" &&
F_Inventory[IN_DOCDATE] >= EARLIER(F_Inventory[IN_DOCDATE])
)
)
RETURN MAX(0, Receipts - Used)

 

🌟 I hope this solution helps you unlock your Power BI potential! If you found it helpful, click 'Mark as Solution' to guide others toward the answers they need.
💡 Love the effort? Drop the kudos! Your appreciation fuels community spirit and innovation.
🎖 As a proud SuperUser and Microsoft Partner, we’re here to empower your data journey and the Power BI Community at large.
🔗 Curious to explore more? [Discover here].
Let’s keep building smarter solutions together!

View solution in original post

3 REPLIES 3
v-sshirivolu
Community Support
Community Support

Hi @rajasekaro ,

I would also take a moment to thank @grazitti_sapna , for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.
 

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.

 

Hi @rajasekaro ,

I hope the above details help you fix the issue. If you still have any questions or need more help, feel free to reach out. We’re always here to support you

 

grazitti_sapna
Super User
Super User

Hi @rajasekaro,

 

Create a measure for running balance for receipts

 

CumulativeReceipts =
CALCULATE(
SUM(F_Inventory[qty]),
FILTER(
F_Inventory,
F_Inventory[Item] = EARLIER(F_Inventory[Item]) &&
F_Inventory[TRTY] = "RCPT" &&
F_Inventory[IN_DOCDATE] <= EARLIER(F_Inventory[IN_DOCDATE])
)
)

 

Dax for running balance for issues

CumulativeIssues =
CALCULATE(
SUM(F_Inventory[qty]),
FILTER(
F_Inventory,
F_Inventory[Item] = EARLIER(F_Inventory[Item]) &&
F_Inventory[TRTY] = "ISSU" &&
F_Inventory[IN_DOCDATE] <= EARLIER(F_Inventory[IN_DOCDATE])
)
)

 

DAX for Remaining stock per receipt

 

RemainingQty =
VAR Receipts = F_Inventory[qty]
VAR Used = CALCULATE(
SUM(F_Inventory[qty]),
FILTER(
F_Inventory,
F_Inventory[Item] = EARLIER(F_Inventory[Item]) &&
F_Inventory[TRTY] = "ISSU" &&
F_Inventory[IN_DOCDATE] >= EARLIER(F_Inventory[IN_DOCDATE])
)
)
RETURN MAX(0, Receipts - Used)

 

🌟 I hope this solution helps you unlock your Power BI potential! If you found it helpful, click 'Mark as Solution' to guide others toward the answers they need.
💡 Love the effort? Drop the kudos! Your appreciation fuels community spirit and innovation.
🎖 As a proud SuperUser and Microsoft Partner, we’re here to empower your data journey and the Power BI Community at large.
🔗 Curious to explore more? [Discover here].
Let’s keep building smarter solutions together!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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.

Top Solution Authors
Top Kudoed Authors