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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Sandeep_PowerBI
Frequent Visitor

SumProduct with Power BI

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... 

Sandeep_PowerBI_1-1686603057129.png

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

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.

vstephenmsft_0-1688103889722.png

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] )
    )

vstephenmsft_1-1688104374565.png

 

   

                                                                                                                                                         

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.           

 

View solution in original post

11 REPLIES 11
Anonymous
Not applicable

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.

vstephenmsft_0-1688103889722.png

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] )
    )

vstephenmsft_1-1688104374565.png

 

   

                                                                                                                                                         

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.

 

some_bih_0-1688551433607.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






some_bih
Super User
Super User

Hi @Sandeep_PowerBI  I organized your table as shown on first picture below, new calculate column

Product = ROUND(Sheet24[Amount]*Sheet24[Weight],2)

and created 3 Measures below. On last picture there are results. I hope this help.

Amount_Line = SUM(Sheet24[Amount])
Sum Product = SUM(Sheet24[Product])
Weighted Avg =
    DIVIDE([Sum Product], [Amount_Line])
Adjust Sheet24 for your table name
 
 

My Excel from your data

some_bih_0-1686723072012.png

 

some_bih_1-1686723180504.png

 

some_bih_2-1686723206296.png

 

 





Did I answer your question? Mark my post as a solution!

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) 

Screenshot_2023-06-14-09-34-29-217-edit_com.android.chrome.jpg

some_bih
Super User
Super User

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 





Did I answer your question? Mark my post as a solution!

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





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






How to attach excel sheet?

Sandeep_PowerBI_0-1686683613088.png

 

 

Hi @Sandeep_PowerBI check part example from link, ot cpuld be in web page values

 

https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-Get-Your-Question-Answered-Qu... 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.