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
gunasai
Helper I
Helper I

DAX to calculate a column from two tables with no relationship.

Hey,

 

I have the following two tables,

the first is pick_det and the second is order_det

2.png 

 

joined in this way,

4.png

 

I want a table as follows,

Ord_numitem_codeQty_to_pickQty_pickedShipment_numSales_price

Total_price

(Qty_to_pick*Sales_price)

90082999079829648099.195955.12
900829993110811200096.377644.00
900829995654140098.340

 

I tried adding the sales_price column from order_det to the pick_det and got as follows,

3.png

 

How do I write a DAX in general to link two tables that has no relationship?

 

(Note: I have many orders and also many shipment_num, in this case '9' because I care only abt the most recent shipment_num)

 

I want to calculate the total sales price (qty_picked*sales_price of that item)

8 REPLIES 8
cassidy
Power Participant
Power Participant

The relation appears to be on Order Number and Item Number, but you don't have an Item table. 

 

Are you able to add an Item (product) table so that your Order_det and Pick_det can have a relationship through it?

Yes, I can add the Item (product) table and Order_det and Pick_det can have a relationship on Item_code.

But, the problem is. the item table does not have the sales_price in it. 
The only way I can get the sales_price is from the Order_det table. 

 

Do you still want me to add the Item (Product) table with relationship to both order_det and pick_det on Item_code? 

You likely have two things happening.

 

1. When you see the Sales_Price repeating at the same wrong value right that, it's because it doesn't know what the Item is (solve that by adding the relationship to an Item table)

 

2. I'd guess the Data Format of your ORD_NUM in your Order_det does not match the Data Format of your ORD_NUM in your ORDER_HEADER.  Double check those both are Text.  It should be repeating $23.90 right now, pre Item relationship.

1. I edited my question with a new image added.

2. Ord_num columns in both Order_det and Order_header has the same data format (text).

Looks good.  Well, it's definitely an issue with the Relationship still, either formatting or relationship type.  You shouldn't need DAX to resolve this.

 

I don't have any other advice unless you're able to share the file.  It seems to be pretty generic data.

Can you pleae guide me on how to share my file? I have never shared a file to the community before.

Hi,

Upload your workbook to Google Drive and share the download link here.


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.