Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

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)

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

5 Replies

  • bolfri's avatar
    bolfri
    Solution Sage

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

    • Anonymous's avatar
      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!