1 Reply Latest reply on Aug 29, 2018 6:07 AM by Brandon Kidwell

# Weighted Average Calculating with Null Rows?

I am applying a weighted average to some dummy Box Office Data. I created a calculated value for the weighted average using the box office. It works when all the rows are populated with data.

The first column is if I applied a weighted average via the box office gross (ie. a movie with more sales should factor more into average).

The second column is a standard tableau calculation, taking the average of the values.

The problem is, when there are nulls for the demographic, the corresponding movie's box office is still being added to the total.

I did the math in Excel to double check my numbers.

So what I am trying to do is calculate the weighted average, with a box office total of the films that have the relevant demographic info, the last row of my excel screenshot. Any ideas?

• ###### 1. Re: Weighted Average Calculating with Null Rows?

Hello Aleksandr,

You can create the calculated field listed below to achieve your desired results.

SUM([Domestic Box Office]*[Age 10<])

/

SUM(IF [Age 10<]>0

THEN [Domestic Box Office]

ELSE 0

END)

Thanks and best,

Brandon