Forum Discussion

MiKeZZa's avatar
MiKeZZa
Post Patron
5 years ago

Weighted average issue

I am preparing an weighted average and I want this output:

 

But my measure is this (based on a measure and a column):

 

Weighted Average Discount Rate = 
VAR Discount = AVERAGE('Product'[DiscountRate]) 
VAR AveragePos = [Average Position] 
Var TotalPos = CALCULATE([Average Position], ALLSELECTED(Transactions)) 
VAR PercentageOfTotal = AveragePos/TotalPos 
Var ResultPerLine = SUMX('Product', PercentageOfTotal * SUM('Product'[DiscountRate])) 
VAR Result = IF(HASONEVALUE('Product'[Contractnumber]), ResultPerLine, 8.47) 
RETURN Result

 

 And as you can see 8.47 is hardcoded, that is the needed solution. That is the total off the lines. Can somebody help me achieve this? I'm almost there....

 

I have a preview PBIX here: https://gofile.io/d/btaAgK

1 Reply

  • v-kelly-msft's avatar
    v-kelly-msft
    Community Support

    Hi MiKeZZa ,

     

    Sorry but I am not quite sure about your issue,could you pls advise me your expected output?Or point out where the issue is...

     


    Best Regards,
    Kelly

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