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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

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: 

Screenshot 2023-11-16 101509.png

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

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?


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

Hi Ashish, Yes that is correct, the outcome would need to be shown in every row.

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


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

Adding the loading date, the order table would look like this: 

 

Order NumberLoading DateMaterial_PlantNet_weight
125/12/2023001_X10
227/12/2023002_X20
327/12/2023003_X10
405/12/2023001_X10
508/12/2023001_X20
608/12/2023001_X50
716/12/2023003_X10
831/12/2023001_Y20
906/12/2023001_Y10
1008/12/2023002_Y20
1125/12/2023004_Y10
1226/12/2023004_Y50
1303/12/2023005_Y30

 

And the report would look like this: 

miriam_kuijper_0-1700751940446.png

I would be happy with having the calculated remaining inventory measure to reflect the inventory minus all summarized order weight on each row, like this: 

Order NumberLoading DateMaterial_PlantNet_weightProj Inventory 1
125/12/2023001_X1010
227/12/2023002_X2080
327/12/2023003_X10-20
405/12/2023001_X1010
508/12/2023001_X2010
608/12/2023001_X5010
716/12/2023003_X10-20
831/12/2023001_Y20-30
906/12/2023001_Y10-30
1008/12/2023002_Y20-20
1125/12/2023004_Y1040
1226/12/2023004_Y5040
1303/12/2023005_Y3070

 

Or even better, in the way that lbendlin has proposed with a decreasing projected inventory, but then based on loading date sequence rather than order number sequence.

Order NumberLoading DateMaterial_PlantNet_weightProj Inventory 2
125/12/2023001_X1010
227/12/2023002_X2080
327/12/2023003_X10-20
405/12/2023001_X1090
508/12/2023001_X2070
608/12/2023001_X5020
716/12/2023003_X10-10
831/12/2023001_Y20-30
906/12/2023001_Y10-10
1008/12/2023002_Y20-20
1125/12/2023004_Y1090
1226/12/2023004_Y5040
1303/12/2023005_Y3070

 

Thanks again for your help.

Hi,

Try these calculated column formulas

Inventory = RELATED(Inventory[Inventory])
Cumulative net weight = CALCULATE(SUM(Data[Net_weight]),FILTER(Data,Data[Material_Plant]=EARLIER(Data[Material_Plant])&&Data[Loading Date]<=EARLIER(Data[Loading Date])&&Data[Order Number]<=EARLIER(Data[Order Number])))
Projected inventory = [Inventory]-[Cumulative net weight]

Hope this helps.

Ashish_Mathur_0-1700794310875.png

 


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

lbendlin_0-1700341194724.png

see attached

 

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.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.