KReEd
KReEd

Reputation: 378

Create SUMPRODUCT formula into dax format in power bi

I have a formula in excel : =SUMPRODUCT(E2:E6, D2:D6)/SUM(E2:E6) which gives 3.66, I want to create the same formula in DAX.

my data -

D E
1 cost number
2 1 1
3 2 2
4 3 3
5 4 4
6 5 5

Please help me to get my O/P in dax, thanks in advance!!!

Upvotes: 1

Views: 14758

Answers (1)

Marcus
Marcus

Reputation: 4005

You'll need to use SUMX to iterate over your table to multiply row-level values and sum them. In the below measure the dividend is your SUMPRODUCT equivalent.

Measure :=
DIVIDE ( 
    SUMX ( 
        'Table',
        'Table'[cost] * 'Table'[number]
    ),
    SUM ( 'Table'[number] )
)

Upvotes: 2

Related Questions