Forum Discussion
Incorrect result - SUMX two tables
- 4 years ago
Hi Thigs
Based on what you've described, here is what I would suggest if I were creating these calculations:
Create these measures:
Order Quantity = SUM ( Orders[Quantity] )Total Weight = SUMX ( SUMMARIZE ( Orders, 'Dimensions'[weight] ), 'Dimensions'[weight] * [Order Quantity] )The Total Weight measure takes the distinct weights for SKUs appearing in the Orders table, and multiplies these by the corresponding Order Quantity and sums.
Then for the average weight, did you want the average weight per order?
You would first need a measure that returns the Order Count, either by counting distinct Order Numbers, or counting rows of Orders (whichever is correct), i.e.:
Order Count = DISTINCTCOUNT ( Orders[Order Number] )or
Order Count = COUNTROWS ( Orders )Then the average weight per order would be:
Order Average Weight = DIVIDE ( [Total Weight], [Order Count] )Does the above help get the result you were looking for?
Please post back if needed.
Regards,
Owen
Hi Thigs
Based on what you've described, here is what I would suggest if I were creating these calculations:
Create these measures:
Order Quantity =
SUM ( Orders[Quantity] )Total Weight =
SUMX (
SUMMARIZE ( Orders, 'Dimensions'[weight] ),
'Dimensions'[weight] * [Order Quantity]
)
The Total Weight measure takes the distinct weights for SKUs appearing in the Orders table, and multiplies these by the corresponding Order Quantity and sums.
Then for the average weight, did you want the average weight per order?
You would first need a measure that returns the Order Count, either by counting distinct Order Numbers, or counting rows of Orders (whichever is correct), i.e.:
Order Count =
DISTINCTCOUNT ( Orders[Order Number] )
or
Order Count =
COUNTROWS ( Orders )
Then the average weight per order would be:
Order Average Weight =
DIVIDE ( [Total Weight], [Order Count] )
Does the above help get the result you were looking for?
Please post back if needed.
Regards,
Owen
- Thigs4 years ago
Helper IV
Ah! Perfect! Thanks SO much!