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! Learn more

Reply
Gunteris
Regular Visitor

Dax measure for calculating remaining quantity of inventory, of a selected date

Hello, I have encountered a problem, trying to write a  measure.

 

This measure should account for price per unit in Received and Warehouse.
Warehouse is simple because both tables Received and Issued has Warehouse. Price per unit is different, the issued item has no price per unit, so the logic should be that the first items that arrive in the warehause are the first items issued. For example: I have received 5 item a worth 0.5 per unit and 6 item a worth 0.6 per unit, then issue 7 items, so the first ones to go are items worth 0.5 per unit, and because there are 2 more items to issue i have to take them from the newer batch that cost 0.6 per unit. So after all calculations i should be left with 4 items worth at 0.6 per unit.


An example with dummby data:

I have 3 tables in power bi:
1st table is Received 

Date                        Item                 Warehause                

PricePerUnit                   

QTY(Received)           

2024-05-1512ags13.53
2024-05-1712ags13.87
2024-06-0112ags24.59
2024-06-0512ags13.53

2nd table is Issued:

Date                          Item               Warehause               QTY(Issued)                    
2024-05-1812ags15
2024-06-0312ags28
2024-06-1012ags16

3rd table is a simple DateTable with Date

 

So if i would select that i want to see Remaining quantities from 2024-05-19 i would get:

Item                   Warehause            PricePerUnit           RemainingQTY(New Measure)              
12ags13.50
12ags13.85


And if I would want to see Remaining quantities from  2024-06-18 i would get:

Item              Warehause                 PricePerUnit                   RemainingQTY(New Measure)            
12ags13.52
12ags13.80
12ags24.51


Any help with this measure would be highly appreciated.

2 REPLIES 2
Anonymous
Not applicable

Hi @Gunteris ,

 

Are you missing the data of the number of issued pieces in the table? Because according to your current description, I can't know how many you have issued, so I can't get the remaining number on the selected date.

 

I hope you can share more information so that we can better help you solve the problem.

 

Best Regards,

Clara Gong

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @Anonymous, I fixed the mistace, thank you for pointing it out.

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.