I'm trying to figure out a formula that will find the average of the top 50th percentile of a data set.

Example:
Data Set:
1
2
3
4
5
6

Top 50th percentile {4,5,6}
average(4,5,6)=5

There is an excel formula "percentile" but it only returns the 50th percentile value, not a data set that I can average.