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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
guptav13
Frequent Visitor

Calculating Inventory using sales out and sales in

Hi , I want a new measure calculated inventory in addition to the inventory like below.

guptav13_0-1664860165384.png

 

I want to take January as starting inventory and then calculate subsequest months inventory. So suppose for a particular SAPID, COUNTRY, CFN combination  JAN  Inventory was 100, then the FEB calculated inventory should be (JAN INVENTORY for that SAP COUNTRY CFN combination - FEB SALESOUT for that SAP COUNTRY CFN combination + FEB SALES IN for that SAP COUNTRY CFN combination)

 

guptav13_1-1664860584056.png

 

 

 

 

 https://drive.google.com/file/d/1Z_Y8ETTn0_iqON44f5_CstXQPOi4vjqI/view?usp=sharing 

2 REPLIES 2
ImkeF
Super User
Super User

Hi @guptav13 ,
if you transform your input data a bit before loading into the data model and include a transformation that reverts the sign of the "Sale Out"-figures, you could use a DAX running total measure on it.
If you need help with the transformation, please include usable sample data (

https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-... )

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Greg_Deckler
Super User
Super User

@guptav13 Well, unfortunately this seems to be a scenario where you need "previous value" or, in other words, it is a recursive problem and DAX does not like that kind of thing. Previous Value (“Recursion”) in DAX – Greg Deckler

 

Power Query supports recursion but it's a pain and is ugly. @ImkeF @edhans 

(1) Fun with Graphing in Power BI - Part 5-by-5 | LinkedIn

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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