2 Replies Latest reply on Dec 1, 2016 6:17 AM by Christian Mangold

    Weighted average with different groups in a variable

    Santiago Calvo

      Hi,

       

      I´m needing some help.

      What I want to do is calculate the weighted average of a variable.

      The particularity that is complicating me, is that in the sample I have another variable that divides the values into 2 groups, therefore, some of the values of the average to calculate belong to group 1 and others to group 2.

      The average of the Variable should be weighted, group 1 with 28%, group 2 with 72% and ignore null values.

      Do you understand what I want to do?

      Thank you.

       

      Example:

       

      GroupsVariable
      18
      25
      18
      29
      1
      27

       

      AVG(Variable) = ((8+8) / 2) * 0.28 + ((5+9+7) / 3) * 0.72