Forum Discussion

danakajoel's avatar
danakajoel
Frequent Visitor
5 years ago
Solved

SUMPRODUCT in Matrix Visual

HI,

 

I have a relatively simple dataset copied below where I am seeking to replicate SUMPRODUCT from Excel by working out the difference between sub asset classes between two dates and applying a weighting. I have been able to create the measure but it is displaying oddly in the Matrix visual in Power BI desktop so I am hoping someone can point me in the direction of what I need to add:

 

BB SummarySub AAAttributeValueWeight
GiltsGilt Long   30 June 20213941.190.25
GiltsGilt Long31 May 20213912.910.25
GiltsGilt Short30 June 2021305.480.75
GiltsGilt Short31 May 2021304.780.75

 

The table is called "Benchmark Performance (GBP)" and I have been able to create a measure as follows:

 

Value % difference from Period Start GBP =
VAR STARTVALUE = CALCULATE(SUM('Benchmark Performance (GBP)'[Value]), 'Date'[Variable Date] IN { "Period Start" })
VAR ENDVALUE = CALCULATE(SUM('Benchmark Performance (GBP)'[Value]),'Date'[Variable Date] IN { "Period End" })
VAR BBPERF = DIVIDE(ENDVALUE-STARTVALUE,STARTVALUE)
VAR RESULT = SUMX('Benchmark Performance (GBP)','Benchmark Performance (GBP)'[Weight]*BBPERF)
    RETURN
RESULT
 
This is returning what I'd expect at Sub Asset Allocation level (SUB AA) in a visual but the wrong weighting for BB Summary level:
 

In the above example, I would expect the output to be Gilts 0.18+0.17% = 0.35%

 

Any pointers greatly appreciated

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi danakajoel 

     

    try it

    test= SUMX(VALUES('Benchmark Performance (GBP)'[Sub AA]),[Value % difference from Period Start GBP])

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi danakajoel 

     

    try it

    test= SUMX(VALUES('Benchmark Performance (GBP)'[Sub AA]),[Value % difference from Period Start GBP])
    • danakajoel's avatar
      danakajoel
      Frequent Visitor

      Hi Vera. Absolutely perfect. Thank you. I'd spent hours investigating and trying ISINSCOPE etc to no avail. I'll need to read up on the VALUES function to better my understanding but problem solved 🙂