Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Aggregation using Sumproduct() in Power BI

I'm working on creating a Power BI report to emulate an existing Excel report. In the excel report, they are using the sumproduct() function to calculate and aggregate the data to determine MyCompany's price index on the product and market level. The data set is as follows: 

 

1st Lev aggregation = sumproduct(1st Lev Units,1st Lev Index)/sum(1stLev Units)

Rival1 & 2= Provided

Item = Provided

1st Level Units = Provided

1st Level Index = Provided

1st Level Line Weight = 1st Level Units * 1st Level Index for Rival1 and Rival2

1st Level Weighted Average = Sum 1st Level Line Weight / Sum 1st Level Units

 

2nd Lev aggregation = sumproduct(2nd Lev Units, 2nd Lev Index)/sum(2ndLev Units)

MyCompany = Provided

1st Level Weighted Average = Calculated (by Rival#)

2nd Level Line Weight = 1st Level Weighted Average (by Rival#)* MyCompany Units

2nd Level Weighted Average = Sum 2nd Level Line Weight / Sum MyCompany Units

 

Company       Item   Units   Index     1st Lev Line Wt     1st Sum Line Wt       1st Sum Units     1st Lev Wt Ave  

MyCompany  A85    120     

Rival1             B23    150     0.8506     127.59

Rival1             B44    73       0.9584      69.9632

Rival1             B75    22       0.8756      19.2632                     216.82                    245                     0.8850

Rival2             C18    2         1.0596      2.1192                       2.1192                     2                        1.0596

 

MyCompany   A66     85      

Rival1             B23    150      0.8506      127.59

Rival1             B44     73       0.9584      69.9632

Rival1             B99     15       1.0468       15.702                     213.82                     238                     0.8960

Rival2             C18       2       1.0596      2.1192                       2.1192                     2                        1.0596

 

MyCompany   A77     65

Rival1              B44     73       0.9584      69.9632

Rival1              B99     15       1.0468      15.702                   85.665                      88                        0.9735

Rival2              C18       2       1.0596      2.1192

Rival2              C33     120      0.9951     119.412                 121.53                      1

 

Company                     Item   Units   Rival Index     2nd Lev Line Wt     2nd Sum Line Wt       2nd Sum Units     2nd Lev Wt Average

MyCompany-Rival1     A85     120    0.8850            106.20

MyCompany-Rival1     A66      85      0.8960            76.16

MyCompany-Rival1     A77      65     0.9735             63.28

MyCompany-Rival2     A85      120    1.0596            127.15

MyCompany-Rival2     A66      85      1.0596            90.07

MyCompany-Rival2     A77      65       0.9962           64.75

 

MyCompany-Rival1                                                                                          245.63                      270                           0.9098

MyCompany-Rival2                                                                                          281.97                      270                           1.0443

 

MyCompany                                                                                                      527.6                       540                           0.9770

 

I am able to complete the 1st level aggregation process, however I am having trouble completing the 2nd level aggregation. My problem is finding a way to aggregate the rival index (1st Lev Weighted Average) to the 2nd level to complete the calculations. If you know of a way to get this completed, I would greatly appreciate the advice,

 

Indraneel Dutt

 

3 Replies