Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago

Conditional Measure for specific row across two tables

Dear all,

 

I am looking to include a measure in my report which calculates the difference between inventory and open orders. The values come from different source tables which are connected by material as common value. The outcome of the measure should show the inventory balance for the specific material that is on the order showing in the corresponding row of the report. 

My report looks like this: 

In a new column, I want to add the measure showing inventory balance, so for the first row with order 1, it should show 10 as inventory balance (100 inventory minus open orders of 10 , 10 , 20 and 50). All measures with substraction that I tried give me results that are not corresponding to the single material on the row. Which measure should I use for inventory balance to reflect the correct value for this material specifically on the correct row in the report? 

 

Thanks in advance for your help.

 

Below the source tables that I use, which have a relationship for Material_Plant.

 

Order NumberMaterial_PlantNet_weight
1001_X10
2002_X20
3003_X10
4001_X10
5001_X20
6001_X50
7003_X10
8001_Y20
9001_Y10
10002_Y20
11004_Y10
12004_Y50
13005_Y30

 

Material_PlantInventory
001_X100
002_X100
004_Y100
005_X100
005_Y100

7 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you so much for this! An added complexity in my data set (I simplified it for the purpose of the post) is that every order also has a loading date, and orders with a higher order number could have an earlier loading date than an order with a lower order number. Is there a way to reflect loading date in your code, so that an order that loads earlier is consuming inventory first? I appreciate the help.

  • Hi,

    So in that new column (result of a measure), you want to show 10 in each row where 001_X is found?  Am i correct?

    • Anonymous's avatar
      Anonymous
      Not applicable
      Hi Ashish, Yes that is correct, the outcome would need to be shown in every row.
      • Ashish_Mathur's avatar
        Ashish_Mathur
        Super User

        Since there is an additional complexity (as mentioned by you in another post), share a representative dataset and show the expected result.