Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Helper I
Helper I

Calculating value based on columns in two different tables

Hi - Newbie question...  
I've searched hard for a solution to this question and have tried several different ideas but keep getting an error message or values that do not make sense.

I have two tables:


which contains several columns including ProductCode and QtyOrdered





which contains columns including ProductCode, StockQty and Warehouse

Packaged items ready for dispatch are in Warehouse 1

There is a Many-to-Many, two way relationshp on the ProductCode

To help production, I have created a report with a Matrix visual which shows the ProductCode in the rows, and then two columns - the QtyOrdered and the StockQty.  The data is filtered on Warehouse = 1
This works fine




Now I want to display the shortfall in a third column.

Even a simple attempt to create a new column in the WarehouseStock using the Related DAX function 

Shortfall= related(CustomerOrders[QtyOrdered])

  fails with the error


The column 'CustomerOrders[QtyOrdered]' either doesn't exist or doesn't have a relationship to any table available in the current context.

What am I doing wrong?

Thanks in advance !


You would propose that you extract the product/item object into its own dimension table, which then feeds the inventory and backorder fact tables with a unique address of 1:* each.

View solution in original post

Not applicable

Hi everyone, 

I need help with solving one problem. 

Take a look at this demo table: 




We have 4 different columns, one is "client", the second one is "transporter". Some of our clients are also and transporter. 
I want to make a mutual column and summarize money we earn cooperating with that client ( sum of SUM EUR) - Looking column "client" and "SUM EUR" column, and looking the "Transport" column and the column "price to transporter". 

I want to see how much money we give to transporters and how much they give us as a client we work for. 

For example, "client 8" as a client gives us 420€, but we give "client 8" as a transporter 300€. 

I just want to compare these two values with mutual clients I have in column "client" and column "Transporter". 

Thanks in advance. 


Super User
Super User

"There is a Many-to-Many, two way relationshp on the ProductCode" 


Please explain the rationale behind this decision.  Please show your data model.

Here is an example of the data in the two tables



DateCustomer RefPurchaseOrderRefProductCodeQtyOrdered


From this I can calculate that I need A1 - 27 units, B1 - 20 units etc
Of course there is much more data in the table, so I am interested in the number of units required this week


and WarehouseStock




etc.  I can calculate that I have 100 


This structure is inherited from a third party package which we connect to via SQL so I have no control over the structure

Please show a picture of your Power BI data model. Third icon in the left bar.




Here it is.   Note I've considerably simplified the description in explaining the issue above.



You would propose that you extract the product/item object into its own dimension table, which then feeds the inventory and backorder fact tables with a unique address of 1:* each.

Helpful resources

PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors