Relation custom aggregator with walk
You can use walk to build custom aggregators. This example calculates the geometric mean of the revenues.
relation year, revenue
insert 1980, 520
insert 1981, 700
insert 1982, 360
insert 1983, 490
insert 1984, 432
insert 1985, 400
print
set product = 1
set counter = 0
walk
set product = product * revenue
set counter = counter + 1
end walk
extend geometricmean = pow(product,1/counter)
project geometricmean
print
year | revenue |
---|---|
1980 | 520 |
1981 | 700 |
1982 | 360 |
1983 | 490 |
1984 | 432 |
1985 | 400 |
geometricmean |
---|
472.270280915477 |