Forum Discussion

NJ81858's avatar
NJ81858
Helper IV
3 years ago
Solved

Weighted Average

Hello,   I am trying to calculate a weighted average between multiple different fields that all have set weights on them and my calculation isn't quite calculating correctly.   The values that cu...
  • v-jianboli-msft's avatar
    3 years ago

    Hi NJ81858 ,

     

    Based on your description, I have created a simple sample:

    Please try:

    Measure1 = 
    VAR _variable = CALCULATE(
        DIVIDE(
            CALCULATE(
                SUMX('Metric 1', [Value]), FILTER('Metric 1', [ID] = [ID])),
            CALCULATE(
                SUMX('Goal Table', [Goal Metric 1]), FILTER('Goal Table', [ID] = [ID]))))
    
    RETURN IF(_variable >= 1.5, 1.5, _variable)
    
    Measure2 = 
    VAR _variable = CALCULATE(
        DIVIDE(
            CALCULATE(
                SUMX('Metric 2', [Value]), FILTER('Metric 2', [ID] = [ID])),
            CALCULATE(
                SUMX('Goal Table', [Goal Metric 2]), FILTER('Goal Table', [ID] = [ID]))))
    
    RETURN IF(_variable >= 1.5, 1.5, _variable)
    
    Measure3 = 
    VAR _variable = CALCULATE(
        DIVIDE(
            CALCULATE(
                SUMX('Metric 3', [Value]), FILTER('Metric 3', [ID] = [ID])),
            CALCULATE(
                SUMX('Goal Table', [Goal Metric 3]), FILTER('Goal Table', [ID] = [ID]))))
    
    RETURN IF(_variable >= 1.5, 1.5, _variable)
    
    Weighted Average = 
    VAR _group1 = [Measure1]*0.3
    VAR _group2 = [Measure2]*0.25
    VAR _group3 = [Measure3]*0.45
     
    RETURN DIVIDE((_group1 + _group2 + _group3), (0.3+0.25+0.45))

    Final output:

    Best Regards,

    Jianbo Li

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.