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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
aray99
Regular Visitor

How to do a sum product but over multiple columns

Hello Power BI Community,
I have found many methods to do a sumproduct in powerbi but my use case is a bit different.

EDIT:
-----------
Here's a sample of my raw data in text. We can call this table A.

CategoryTPRangeNo_AcctsLoss Amt
NR-60885743194
NR-61-5997895661986
NR-6600-6498532961052
NR-5650-69912368401071
NR-4700-749262685702
NR-3750-799134774554
NR-2>=800661154285
NR-10702984427
NR01-5993150461984
NR1600-649877738155
R2650-6991480603471
R3700-74948172836
R4750-79914809341510
R5>=8001285418974
R608785021447
R71-59913848621823
R8600-649544773667
R9650-6998695671819
R10700-74914852621554
R11750-79989739193
R12>=800160044608
R13 1564501990

Here's a matrix I made in powerbi which calculates the sum of num_of_acct by range for R and then calculates percentage of total of the sum. The same is done for NR. This can be table B.

Row LabelsSum of Num_of_Accts%age
08785029%
(blank)1564502%
1-599138486214%
600-6495447736%
650-699235017024%
700-749153343416%
750-799157067316%
>=800144546215%
 Grand total9864326100%


Here's a matrix I made in powerbi by making two measures to calculate the same percentages above and combining the R and NR data: This can be table C.

Range%age R%age NR
09%20%
(blank)2%0%
1-59914%14%
600-6496%22%
650-69924%16%
700-74916%3%
750-79916%17%
>=80015%8%

Here's a matrix I made for loss_amt/num_of_acct. Columns are time period (tp) and rows are Category. This can be table D.

Range-6-5-4-3-2-10123456
00.000----0.001------0.002
>=800----0.000------0.001-
1-5990.003-----0.006------
600-6490.001------0.000-----
650-699-0.001------0.000----
700-749--0.003------0.017---
750-799---0.000------0.001--
(blank)-------------

As output, I want the sumproduct between the values in each column with the %age R values and %age NR.

So starting in time period 0, don't need the ones before that. The result is the below. I made up the dummy data numbers so they're weird but the real data would have numbers. This can be table E.

Category

0123456789
R0.0003477892.7533E-05001563.5304076.74823E-050000
NR0.00090.00000.00000.00000.00000.00000.00000.00000.00000.0000

I need help to make the above table. 

To make the first column, first row in table E, we first go to table D then take all the values from the column 0 (excluding the values corresponding to blank and 0 in the Range rows). Then we go to table C, we take all the values from the column %age (excluding the values corresponding to blank and 0 in the Range rows). Now we get the sumproduct of all these values and put it in first row and first column of table E.
For first column and second row of table E, we first go to table D then take all the values from the column 0 (excluding the values corresponding to blank and 0 in the Range rows). Then we go to table C, we take all the values from the column %age NR (excluding the values corresponding to blank and 0 in the Range rows). Now we get the sumproduct of all these values and put it in second row and first column of table E.
To make the second column, first row in table E, we first go to table D then take all the values from the column 1 (excluding the values corresponding to blank and 0 in the Range rows). Then we go to table C, we take all the values from the column %age (excluding the values corresponding to blank and 0 in the Range rows). Now we get the sumproduct of all these values and put it in first row and second column of table E.

For second column and first row of table E, we first go to table D then take all the values from the column 1 (excluding the values corresponding to blank and 0 in the Range rows). Then we go to table C, we take all the values from the column %age NR (excluding the values corresponding to blank and 0 in the Range rows). Now we get the sumproduct of all these values and put it in first row and second column of table E.

Please let me know if I can provide any further information.

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@aray99 This is the general formula for SUMPRODUCT in DAX:

	
SUMPRODUCT = 
    VAR __Table = 
        ADDCOLUMNS(
            'Table1',
            "Value",[Value1] * RELATED(Table2[Value2])
        )
RETURN
    SUMX(__Table,[Value])

It comes from here: S Excel to DAX Translation - Microsoft Fabric Community

 

Otherwise, Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi Greg,
I remade the post and hoping it's better now.
Pls let me know if I can provide any further information.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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