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
samueledenicola
Regular Visitor

Ratio of two sums

Hi everyone, 

I'm trying to calcualte the ratio between two sums. My dataset is built as follows:

  • a table with all the Inventory Fulfillments (associated to Sales Orders, there can be more than one IF for each SO), to each IF is associated a shipping cost;
  • a table with all Sales Orders, each line of the table contains an item in the sales order and the relative amount (€) ordered, it's possible to obtain the total ordered value of the SO by summing all the lines of the table, grouping by SO;

I need to calculate, for each SO, the ratio between the shipping cost and the total value of the order, but I'm having trouble doing so. 

Can you help me? I can share my initial solution nut it doesn't work at all.

Thanks!

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @samueledenicola ,

 

Here I create a sample to have a test.

Table1:

RicoZhou_0-1666085620265.png

Table2:

RicoZhou_1-1666085630035.png

DimSo:

DimSO = VALUES(Table2[Sales Orders])

Relationship:

RicoZhou_2-1666085671804.png

Measure:

Rate = 
VAR _RelativeAmount = CALCULATE(SUM(Table2[Relative Amount]))
VAR _ShippingCost = CALCULATE(SUM(Table1[Shipping Cost]))
RETURN
DIVIDE(_RelativeAmount - _ShippingCost,_ShippingCost)

Result is as below.

RicoZhou_3-1666085704589.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

2 REPLIES 2
v-rzhou-msft
Community Support
Community Support

Hi @samueledenicola ,

 

Here I create a sample to have a test.

Table1:

RicoZhou_0-1666085620265.png

Table2:

RicoZhou_1-1666085630035.png

DimSo:

DimSO = VALUES(Table2[Sales Orders])

Relationship:

RicoZhou_2-1666085671804.png

Measure:

Rate = 
VAR _RelativeAmount = CALCULATE(SUM(Table2[Relative Amount]))
VAR _ShippingCost = CALCULATE(SUM(Table1[Shipping Cost]))
RETURN
DIVIDE(_RelativeAmount - _ShippingCost,_ShippingCost)

Result is as below.

RicoZhou_3-1666085704589.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

amitchandak
Super User
Super User

@samueledenicola , You can have a new column

New column in SO

 

Sumx(filter( Fulfillments , Fulfillments [So] = SalesOrder[SO]), Fulfillments [Qty])

 

refer 4 ways to copy data from one table to another
https://www.youtube.com/watch?v=Wu1mWxR23jU
https://www.youtube.com/watch?v=czNHt7UXIe8

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

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.

Top Solution Authors