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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
caseski
Helper I
Helper I

Calculating the stock level from two tables (in&out) and the starting stock

I've just posted a similar question but I did'n explained the problem very well, I apologize if I'm posting twice but I don't know how to cancel the previous post. I hope that this post would be clear.

I'm trying to build a report using DAX running total calculation to get stock level from data set imported from two DB which record all inbound and outbound movements.

I have two problems:

1) I don't know the DAX formula to sum all movements for data

2) The initial stock quantity is not imported from the data set, it's a known data but I don't know how to use it in the DAX

 

The sample data set are as following (the real data set are more complicated but the following tables simplify well, the only difference are that I have more columns that are not involved in this calculation, that row are thousands as we have many mnovements every day, and that date includes also hour/minute/second).

 

OUTBOUND_TABLE (data imported from the production DB)

 

DATEITEMQUANTITY

02 November 2020

BE013
02 November 2020BE012
03 November 2020CE034
06 November 2020BE013
06 November 2020CE032
12 November 2020ZA023
01 December 2020CE033
03 December 2020ZA022

 

INBOUND TABLE (data imported from the ERP DB)

 

DATEITEMQUANTITY

01 November 2020

BE0130
06 November 2020ZA0120
10 November 2020CE0340
15 November 2020BE0130
30 November 2020ZA0220
30 November 2020ZA023
01 December 2020CE033

 

From the two data set we have all inventory movements (in & out) but we don't have the stock level at the beginning. This information is known and I'm trying to figure out how to use it in my model only one time as a starting point to calculate the correct quantity of stock for each product every day.

 

Let's assume that the stock level of starting point is:

 

DATA

ITEMQUANTITY

30 October 2020

BE01250
30 October 2020CE03410
30 October 2020ZA01180
30 October 2020ZA02110

 

The desired output is a report that calculate the stock level for each item and every day, for example for item BE01 on the 1st November we have quantity = 250 as initial stock (this data is not imported from DB), +30 as inbound, -3 and -2 as outbound = 275 the stock level of item BE01

 

30 October 2020

BE01250
01 November 2020BE0130
01 November 2020BE01-3
01 Novemebr 2020BE01-2

 

Setting the correct initial stock for each item as the data set imported are all inventory movements I could calculate the correct stock level per data and also forecast the consumption.

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @caseski ,

 

How about just using "Append" function in Power Query Editor? For detailed steps, please check:

 

quantity.gifquantity.PNG

 

And then you can calculate running total based on your requirements.

 

 

 

Best Regards,

Icey

 

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

 

View solution in original post

1 REPLY 1
Icey
Community Support
Community Support

Hi @caseski ,

 

How about just using "Append" function in Power Query Editor? For detailed steps, please check:

 

quantity.gifquantity.PNG

 

And then you can calculate running total based on your requirements.

 

 

 

Best Regards,

Icey

 

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

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors