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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

calculate Monthly stock with missing values using future values

Hello comunity! I've been stucked on this for several weeks now!
I'm creating  a monthly report, the problem is that the logic of the ERP  that we are using (SAP) to create the datasource is not that "logical".
The system has  a database table to storage the month end values of the inventory stock, however, the History tables are updated with first movement after a period closure. If there is no movement for several months, then you will not see any history record for all those months that have past. SAP writes only a history record for the month preceding a change in stock or value.

All the periods between 2 records in a history table had the same stock/value all the time, hence you can take the value for those periods from the record following these missing periods.

For example, you could have the following information (I already have created a DataTable in order to show the missing months)

Capture.JPG

I need to calculate the values in a "backward" ways, considering the possibility that there could be more than 1 consecutive missing row.

 

Obviously, the report contains multiple material codes and multiple plants code.
Has anyone done something like this??

1 ACCEPTED SOLUTION

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

5 REPLIES 5
bolfri
Solution Sage
Solution Sage

Can you provide sample data to work with? 🙂 I can show you how to do this.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Thanks for the quick response? Do you mean additional to the picture?
I'm not sure if I can upload files, but here are some examples of how the data appears:

PlantMaterialYearMonthStock
G1041000010691202270
G1041000010691202290
G104100001069120221016
G104100001069120221220
G10410000106912023312

 

I need to be able to create a DAX that calculate the values and the table should look like this:

PlantMaterialYearMonthStock
G1041000010691202270
G1041000010691202280
G1041000010691202290
G104100001069120221016
G104100001069120221120
G104100001069120221220
G10410000106912023112
G10410000106912023212
G10410000106912023312

 



Thanks for your help!

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Awesome! It worked! Thank you very much you saved me!

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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