cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Welsh_Will
Helper II
Helper II

Creating a weight/cost ratio measure

Hi

 

I'm pretty awful with measures, so while I don't think this is particularly difficult I'm struggling to write it out. I have data across two tables, Orders and Shipments. A shipment is made up of one or more orders, so in this example Orders A and B make up Shipment 0001.

 

OrdersWeight
Order A25
Order B30

 

ShipmentsTotal WeightTotal Cost (USD)
Shipment 000155200

 

From this I need to find the cost per order:

 

Shipments[Total Cost] / Shipments[Total Weight] * Orders[Weight]

Order A Cost = 200 / 55 * 25 = $90.91

 

Many thanks!

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hello @Welsh_Will ,

I created two test tables with one or many relationships based on shipment fields.

V-lianl-msft_0-1603089296655.png

Next, create a measure like this:

Measure = var per_weight=
CALCULATE(DIVIDE(MAX('Table (2)'[Cost]),MAX('Table (2)'[weight])))
return CALCULATE(per_weight*MAX('Table'[Weight]))

V-lianl-msft_1-1603089367532.png

.pbix example

Best regards
Liang
If this post helps, then consider Accept it as the solution to help other members find it faster.

View solution in original post

3 REPLIES 3
V-lianl-msft
Community Support
Community Support

Hello @Welsh_Will ,

I created two test tables with one or many relationships based on shipment fields.

V-lianl-msft_0-1603089296655.png

Next, create a measure like this:

Measure = var per_weight=
CALCULATE(DIVIDE(MAX('Table (2)'[Cost]),MAX('Table (2)'[weight])))
return CALCULATE(per_weight*MAX('Table'[Weight]))

V-lianl-msft_1-1603089367532.png

.pbix example

Best regards
Liang
If this post helps, then consider Accept it as the solution to help other members find it faster.

Thank you!

DataInsights
Super User
Super User

@Welsh_Will,

 

How are orders and shipments associated in the data model? Does the Orders table have a column for shipment number?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!