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.
Hi Team,
Please help me with SUMPRODUCT similar with excel in DAX measure... Below are my Actuals in Main Category and Lines. How to get weighted average using SUMPRODUCT logic in DAX command?
I want to get below highlight output using DAX command...
Solved! Go to Solution.
Hi @Sandeep_PowerBI ,
In Power BI, you need to use unpivot and pivot for your data first, and then you can perform calculations.
After transformation, the data is as follows.
Create this measure:
Measure =
VAR _table =
SUMMARIZE (
'Table',
[Line],
[ABC],
[HMP],
"Product", SUM ( 'Table'[ABC] ) * SUM ( 'Table'[HMP] )
)
RETURN
DIVIDE (
SUMX ( _table, [Product] ),
SUMX ( FILTER ( ALL ( 'Table' ), [Line] = MAX ( 'Table'[Line] ) ), [HMP] )
)
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Sandeep_PowerBI ,
In Power BI, you need to use unpivot and pivot for your data first, and then you can perform calculations.
After transformation, the data is as follows.
Create this measure:
Measure =
VAR _table =
SUMMARIZE (
'Table',
[Line],
[ABC],
[HMP],
"Product", SUM ( 'Table'[ABC] ) * SUM ( 'Table'[HMP] )
)
RETURN
DIVIDE (
SUMX ( _table, [Product] ),
SUMX ( FILTER ( ALL ( 'Table' ), [Line] = MAX ( 'Table'[Line] ) ), [HMP] )
)
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you @Anonymous its working...
By,
Sandeep
Hi @Sandeep_PowerBI as I wrote, I organize your excel data into different structure /unpivoting and basically rename your Actual to Weight to follow calculation logic.
In red below you can find example your and mine data.
Proud to be a Super User!
Hi @Sandeep_PowerBI I organized your table as shown on first picture below, new calculate column
and created 3 Measures below. On last picture there are results. I hope this help.
My Excel from your data
Proud to be a Super User!
Hi @some_bih
Thanks for providing solution but in my data, I dont have weight value columns f... Only 2 categories HMP and ABC values...
How did you calc weight (column F)
Hi @Sandeep_PowerBI the best would be to organize columns like amounts should be in one columns and weigths in another column (date is some third columns, if needed).
Check example for similar request https://community.fabric.microsoft.com/t5/Desktop/Weighted-Average-DAX/td-p/1661527
Proud to be a Super User!
Hi,
Thanks for response,
Actually separating in 3 columns is fine. Done in Transaformation unpivot. but, the same calculation is not matching to my requiremet. I want to calculate weighted Average value using DAX...
=SUMPRODUCT(D2:O2,D5:O5)/SUM(D2:O2) - using Excel
=SUMPRODUCT(HMP(D2:O2), ABC(D5:O5))/SUM(HMP(D2:O2))
Thanks,
Sandeep
Hi @Sandeep_PowerBI if possible provide data not as picture so I can use it for testing measure to get your expected output
Proud to be a Super User!
How to attach excel sheet?
Hi @Sandeep_PowerBI check part example from link, ot cpuld be in web page values
Proud to be a Super User!
User | Count |
---|---|
25 | |
10 | |
8 | |
6 | |
6 |
User | Count |
---|---|
31 | |
12 | |
10 | |
10 | |
9 |