cancel
Showing results for
Search instead for
Did you mean:
Frequent Visitor

## SumProduct in measure

Hello technical experts!

I would like to perform a "sumproduct" on two time series in the same datatable. All ID1 should be multiplied by ID2 for all time slots. How can I do this using DAX formulas in a measure?

 Time ID Value 01.01.2018 1 12 02.01.2018 1 14 03.01.2018 1 16 01.01.2018 2 100 02.01.2018 2 200 03.01.2018 2 300

 12*100 + 14*200 + 16*300 = 8800
1 ACCEPTED SOLUTION
Super User I

Hi there,

With your existing table, a measure like this using SUMX will give you the result you're looking for. I've used variables to make the calculation clearer.

SumProduct measure =
SUMX (
VALUES ( YourTable[Time] ),
VAR ValueID1 =
CALCULATE ( SUM ( YourTable[Value] ), YourTable[ID] = 1 )
VAR ValueID2 =
CALCULATE ( SUM ( YourTable[Value] ), YourTable[ID] = 2 )
RETURN
ValueID1 * ValueID2
)

Regards

Owen

Owen Auger

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

My Blog
Connect on Twitter
Connect on LinkedIn
4 REPLIES 4
Super User I

Hi there,

With your existing table, a measure like this using SUMX will give you the result you're looking for. I've used variables to make the calculation clearer.

SumProduct measure =
SUMX (
VALUES ( YourTable[Time] ),
VAR ValueID1 =
CALCULATE ( SUM ( YourTable[Value] ), YourTable[ID] = 1 )
VAR ValueID2 =
CALCULATE ( SUM ( YourTable[Value] ), YourTable[ID] = 2 )
RETURN
ValueID1 * ValueID2
)

Regards

Owen

Owen Auger

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

My Blog
Connect on Twitter
Connect on LinkedIn
Frequent Visitor
Frequent Visitor

Thanks a lot for a quick and great answer!

One more question if I can allow myself.

If ValueID1 represents and hourly price, and ValueID2 represents products sold, and I want to return an weighted avrerage price, then I'll have to devide the answer here with the SUMX of ValueID2 i guess? How can this be done in a good way?

SumProduct measure =
SUMX (
VALUES ( YourTable[Time] ),
VAR ValueID1 =
CALCULATE ( SUM ( YourTable[Value] ), YourTable[ID] = 1 )
VAR ValueID2 =
CALCULATE ( SUM ( YourTable[Value] ), YourTable[ID] = 2 )
RETURN
ValueID1 * ValueID2
)

Community Champion

Just another way of doing it. ....

MEasure =
SUMX ( VALUES ( Table1[Time] ), CALCULATE ( PRODUCT ( Table1[Value] ) ) )
Regards
Zubair

Please try my custom visuals

## Helpful resources

Announcements

#### Manage your user group events

Check out the News & Announcements to learn more.

#### 2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

#### Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

#### Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors
Top Kudoed Authors