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
omartineztr
Frequent Visitor

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
Super User
Super User

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!




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/

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
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.