How to calculate median and P99?

Hi,
I use grafana with jaeger and want to calculate median and P99 of all the durations. However, it is found that reduce in transfrom can only calculate max, min and mean. I am wondering is there any way to calculate median and P99?