To use the derived data measurements in a calculation, treat is as any other measurement. In the
example used here, we use the derived data LifeExpXPop
to accurately
calculate the weighted life expectancy for an aggregation dimension, such as UN
Region or UN Subregion. We do this by dividing the sum of Life Expectancy Population by sum(population)
at the
appropriate aggregate level.
un_region
and un_subregion
. Add the derived
data field Pop
.year
on the Filters shelf ,
and change the expression to [year]=<<year_param:2000>>
.Place the derived data field LifeExpXPop
onto the
Meausres shelf. Notice that it appears as an aggregation,
sum(LifeExpXPop)
.
Using the Enter/Edit Expression window modal, change the definition of the field as follows, and click Save. Notice that we aliased the field.
(sum([LifeExpXPop])/sum([population])) as 'Weighted Life Expectancy'
Click Refresh Visual.
The visual should look similar to this one:
[Optional] To see the correctly calculated Life Expectancy for a UN Region, simply remove UN Subregion from the Dimensions shelf.