The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Good day,
I need to calculate weighted avg for PayItemNo and need help with dax for it.
"Average vs low" number represents a number i calculated based on submitted bids. In the table below (i exported it into excel from query editor) there are multiple instances of the same "pay item". First, they need to be grouped and then calculate weighted avg: total qty of "pay item" * sum of "average vs low" / total qty of "pay items". Thank you.
Thank you!
WeightedAvg =
DIVIDE(
SUMX(
VALUES('YourTable'[PayItemNo]),
SUMX(
FILTER('YourTable', 'YourTable'[PayItemNo] = EARLIER('YourTable'[PayItemNo])),
'YourTable'[Qty] * 'YourTable'[AverageVsLow]
)
),
SUMX(
VALUES('YourTable'[PayItemNo]),
SUMX(
FILTER('YourTable', 'YourTable'[PayItemNo] = EARLIER('YourTable'[PayItemNo])),
'YourTable'[Qty]
)
)
)
This formula uses the SUMX function to iterate over the unique values of 'PayItemNo', then within each iteration, it calculates the sum of the product of 'Qty' and 'AverageVsLow', and divides it by the sum of 'Qty' for that 'PayItemNo'. Finally, it divides the overall sum by the overall sum of 'Qty' for all 'PayItemNo' values.
User | Count |
---|---|
16 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
26 | |
13 | |
12 | |
8 | |
8 |