The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hi all,
I am working with SUMX for the first time and with two different tables.
Yes, I have look at other similar posts, and my formula isn't throwing errors, but it isn't getting the correct result.
I have two tables - Dimensions has a SKU number, height, weight, length and width. Each SKU is unique
Orders has Order Number, SKU number, quantity, and then several other columns not needed for this calculation.
I am trying to figure out the average weight of orders per day.
Here is my formula -
Solved! Go to Solution.
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
Ah! Perfect! Thanks SO much!
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
21 | |
19 | |
18 | |
17 | |
12 |
User | Count |
---|---|
36 | |
34 | |
20 | |
19 | |
14 |