2 Replies Latest reply on Sep 11, 2019 1:04 PM by Bryce Larsen

# Weighted Average

Hello,

I'm attempting to created a calculated field that displays a weighted average (see the attached photo).

The "Purchase Tier" is a product's priority. If the tier is 1, it's a popular item. This is a provided field. What I'm trying to do is calculated a tiering of each customer using a weighted average. If the customer buys a lot of tier 1 items with a high purchase amount, the client will be valued highly, and vice versa.

The column on the right is what I wish to calculate in Tableau. I did this as follows

Purchase tier = x, purchase amount = a

sum(x1*a1+x2*a2+x3*a3+...+xn*an) / (a1+...+an)

• ###### 1. Re: Weighted Average

I attempted to do this by

{FIXED[Customer]:

SUM([Purchase Amount]*[Purchase Tier])/SUM([Purchase Amount]) }

However, it did not give me accurate results.

• ###### 2. Re: Weighted Average

Hi Helen,

This should work:

WINDOW_SUM(SUM([Purchase Tier]*[Purchase Amount]))

/

WINDOW_SUM(SUM([Purchase Amount]))

Result for a small sample set:

1 of 1 people found this helpful