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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

divide between two tables

Hello Community,

 

I would appreciate your help with the below.

 

I want to understand how I can divide the "Despatch"[Quantity] by the "Pallet"[Pallet_Quantity].

 

I have built a relationship between them, based on [Product] columns.

 

I tried SUM(Product[Quantity])/SUM(Pallet[Pallet_Quantity]) but it doesn't work.

 

Despatch  
ProductQuantityDestination
Product1150LocationA
Product1225LocationB
Product175LocationB
Product2100LocationC
Product250LocationD
Product375LocationA
Product325LocationC
Product350LocationB
Product3100LocationD

 

Pallet 
ProductPallet_Quantity
Product125
Product250
Product325

 

Thank you,

 

George

 

 

 

1 ACCEPTED SOLUTION

In that case you need the following measure:

Pallett number =
SUMX ( 'Product Table', DIVIDE ( [Despatch Quantity], [Pallet Quantity] ) )




Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

10 REPLIES 10
Anonymous
Not applicable

Hello @mh2587 ,

 

Thank you for your reply. Please see the data model below.

 

GeorgeGiannakis_0-1636116629242.png

I tried to remove the relationship, it didnt work.

 

Below oyu can see the different results between the manual and the DAX calculations.

 

Manual Calculation

 

 Product1Product2Product3
 15010075
 2255025
 75 50
   100
    
QtySum450150250
PalletQty255025
    
PalletNum18310

 

DAX calculation

 

Row LabelsPalletNum
Product14.5
Product21.5
Product32.5
Grand Total8.5

 

 

Thank you,

 

George

PaulDBrown
Community Champion
Community Champion

Create the model as follows. The Dim Product table must have unique product values (if the product table has unique product values you can use it as the dimension table instead of creating a new one):
model.JPG

 

Create the measures:

 

Despatch Quantity = SUM('Despatch Table'[Quantity])
Pallet Quantity = SUM('Product Table'[Pallet_Quantity])
Despacth Qty by Pallett Qty = DIVIDE([Despatch Quantity], [Pallet Quantity])

 

Create the table with the field from the Dim Product table and add the measures
rrsult.JPG

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Anonymous
Not applicable

Hello @PaulDBrown ,

 

Thank you for your reply.

 

The 'Pallet' table includes unique values for [Product], so there is no need for another table.

 

ProductPallet_Quantity

Product125
Product250
Product325

 

GeorgeGiannakis_1-1636117426645.png

Below you can see the different results between the manual and DAX calculations.

 

Manual calculation shows 31 total number of pallets.

 

 Product1Product2Product3
 15010075
 2255025
 75 50
   100
    
QtySum450150250
PalletQty255025
    
PalletNum18310

 

DAX calculation shows 8.5 total number of pallets, matching to your result as well.

 

Row LabelsPalletNum
Product14.5
Product21.5
Product32.5
Grand Total8.5

 

Having said that, focusing on your results table, if I add the 3 rows of the "Despatch Qty by Pallet Qty" column, it gives me the same result as my manual calculation. 

 

Do you know why the grand total of your results table is not equal to the sum of the 3 rows?

 

Kind regards,

 

George

 

In that case you need the following measure:

Pallett number =
SUMX ( 'Product Table', DIVIDE ( [Despatch Quantity], [Pallet Quantity] ) )




Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Anonymous
Not applicable

Hello @PaulDBrown ,

 

Thank you for your reply.

 

I can confirm that this measure provides the correct result.

 

Can I ask for more feedback related to logic behind the correct measure (why this generates the correct result whereas the previous one not)?

 

GeorgeGiannakis_0-1636123432354.png

 

Thank you

 

George

Well, DIVIDE does at it says. So the division is within the filter context and over the totals.
SUMX, on the other hand, performs the calculation (in this case the DIVIDE) within the filter context (so row by row) and then sums the result of each calculation to deliver the total. Make sense?





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Anonymous
Not applicable

Hello @PaulDBrown ,

 

In case I had a dates table and some other dimension tables, linked to the fact table (despatch table), how should this measure be edited? I am asking because your measure is based on the pallet table (or product table).

 

Thank you

 

George

The table in SUMX should be whatever table is used in the visual to create the filter context of the visual. If more than one table is used in the visual, you will probably need to create an expression along the lines of:
SUMX(SUMMARIZE (FactTable, Dim Table 1 [Column1], Dim Table 2 [Column 2]), ....





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Anonymous
Not applicable

Hello @PaulDBrown ,

 

Yes, it does. Thank you for that.

 

Kind regards,

 

George

mh2587
Super User
Super User

Can you please upload the screenshot of your model or clear the relation between the tables?


Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.