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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
pa2021
Frequent Visitor

How to have Initial Inventory (Earliest Date Values)+Production-Sales=Remaining Inv. (Matrix Table)

Hello,

How would I go about having a dax measure, giving me:

 

Initial Inventory, based on the earliest date found in the date column;

+ (Sum of Production)

- Sum of Sales

= Remaining inventory.

 

Here's a snapshot of the goal:

Goal.PNG

 

Here's a snapshot of the way it is right now:

Current.PNG

 

Any help is appreciated!


Antonio

7 REPLIES 7
amitchandak
Super User
Super User

@pa2021 , Try a measure like

 

calculate(sum(Table[intial Inventory]), filter(Table, Table[Date] = calculate(min(Table[date]), allexcept(Table, Table[product]))))
- Cumm Sales = CALCULATE(SUM(Table[Production Qty]),filter(allselected(Table),Table[Date] <=max(Table[Date])))
+ Cumm Sales = CALCULATE(SUM(Table[Sales Qty]),filter(allselected(Table),Table[Date] <=max(Sales[Date])))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hello @amitchandak !
For some reason, I'm getting the error below:

sintax wrong.PNG

@pa2021 , my mistake, try like 

 

calculate(sum(Table[intial Inventory]), filter(Table, Table[Date] = calculate(min(Table[date]), allexcept(Table, Table[product]))))
-  CALCULATE(SUM(Table[Production Qty]),filter(allselected(Table),Table[Date] <=max(Table[Date])))
+  CALCULATE(SUM(Table[Sales Qty]),filter(allselected(Table),Table[Date] <=max(Sales[Date])))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi again @amitchandak ,

Not certain if this is too much to ask, but here's the output:

Attempt2.PNG

 

The findings:

It's summing initial inventory with itself, giving a doubled result.

It doesn't show Production, Sales and Remaining Inventory for each day. Instead, it gives a total.

Would it be possible to have these 3 columns for each day, besides Initial Inventory, just like to goal below?

Goal.PNG

@pa2021 Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hello @amitchandak ,

Here's a test version: https://drive.google.com/file/d/156jqQf88WR2m48xPZawyKPuG-2RQDDM0/view?usp=sharing

 

Appreciate your time/help.

Here it is, @amitchandak !

Link to download the file:

https://drive.google.com/file/d/1YE2mSPGgvG2Dhyi4alzTbWyNVTPTXvp9/view?usp=sharing
Appreciate your time!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

Top Solution Authors
Top Kudoed Authors