
Median based on Expression
Stefan Wühl Apr 20, 2012 5:35 PM (in response to Sasiwaran Samidurai)You can probably work out an advanced aggregation expression, what is the context (dimensions) of your above expression? Could you post some sample data lines?
An advanced aggregation could look like
=median( aggr( sum([base wt])/sum(total<vehicle> [base wt]), vehicle))

Median based on Expression
Sasiwaran Samidurai Apr 20, 2012 6:34 PM (in response to Stefan Wühl )We have age as dimension. we need to calculate median age.
sample data:
Age Distibution
10 5%
20 10%
30 30%
40 35%
50 15%
60 5%
In this case, the median should be where the cumulative distribution crosses 50%.Here the median age will be 40.
We need a single median age for every vehicle

Re: Median based on Expression
Stefan Wühl Apr 20, 2012 7:02 PM (in response to Sasiwaran Samidurai)You could try something like
=min(aggr( if(rangesum(above(DistributionExpression,0,rowno()))>=50, Age),Age))
where DistributionExpression could be your above expression.
The load order of age must be sorted in ascending order to make this work, so maybe load your sorted age table first in script.
See also attached.

comm51830.qvw 145.8 K


