forums

Use these forums to ask questions and discuss Tableau.

Is there a way to get a weighted average?

I have a value whose average I would like to weight by quantity is there a way to do this?

Basically, I would like to do something like this within Tableau:

SUM(VALUE * QUANTITY) / SUM(QUANTITY)

Thanks!

Comments

It's pretty simple... just create a Calculated Field that uses aggregate functions... and those aggregations are done automatically. So, my field might be:

WeightedAvg: SUM(VALUE * QUANTITY) / SUM(QUANTITY)

When I drag that to a shelf it shows up as:

AGG(WeightedAvg)

and has the right totals calculated.

In the docs it's call "Aggregate Calculations".