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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
RAJASEKAR-O
Regular Visitor

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
but it showing stock movement 
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

 

RAJASEKARO_0-1760692988127.png

 

1 ACCEPTED SOLUTION
grazitti_sapna
Super User
Super User

Hi @RAJASEKAR-O,

 

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)

 

grazitti_sapna_0-1760700465466.png

 

 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.

grazitti_sapna_1-1760700465468.png

 

 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

4 REPLIES 4
grazitti_sapna
Super User
Super User

Hi @RAJASEKAR-O,

 

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)

 

grazitti_sapna_0-1760700465466.png

 

 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.

grazitti_sapna_1-1760700465468.png

 

 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!

Hi @RAJASEKAR-O ,

Thank you for reaching out to the Microsoft Community Forum.

 

Could you please try the proposed solution shared by @grazitti_sapna  ? Let us know if you’re still facing the same issue we’ll be happy to assist you further.

 

Regards,

Dinesh

Hi @RAJASEKAR-O ,

We haven’t heard from you on the last response and was just checking back to see if you have a resolution yet. And, if you have any further query do let us know.

 

Regards,

Dinesh

Hi @RAJASEKAR-O ,

We haven’t heard from you on the last response and was just checking back to see if you have a resolution yet. And, if you have any further query do let us know.

 

Regards,

Dinesh

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors