Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Public Function basPercentileTest()
Dim MyArray(7) As Single
MyArray(0) = 10
MyArray(1) = 20
MyArray(2) = 20
MyArray(3) = 20
MyArray(4) = 30
MyArray(5) = 30
MyArray(6) = 40
MyArray(7) = 50
Debug.Print basPercentile(0.25, 10, 20, 20, 20, 30, 30, 40, 50)
Debug.Print basPercentile(0.5, 10, 20, 20, 20, 30, 30, 40, 50)
Debug.Print basPercentile(0.75, 10, 20, 20, 20, 30, 30, 40, 50)
End Function
Public Function basPercentile(Pctl As Single, ParamArray MyAray() As Variant) As Single
'Explination Courtsey of Rohit Pareek, Ratangarh, India
'Tek-Tips; thread710-170007
'You have a range of data sorted in acsending order....
'e.g. 1567, 1634, 1700, 2100, 2230, 2400, 2550
'and you want to calculate 75th percentile point... then
'All you need to do is to reach to Nth element in the series,
'where N is explained below.
'N = (N-1)* p + 1 ,
'n = number of elements in the series
'and p in our case is .75
'So in our case N=((7-1)*0.75)+1 which is 5.5.
'That means in the above series 5.5th element is your answer
' ....which youcan reach in following way....
'1. Reach to 5th element..Store it into a variable called "BasePercent".
'2. Get the difference of 6th and 5th elements and multiply that by .5,
'Store this into a variable called "ExtraPercent".
'3. Now add BasePercent and ExtraPercent and store the result into
'another cariable "RealPercent"
'.....THIS IS YOUR ANSWER...... YOU CAN TEST YOUR ANSWER BY PUTTING THE SAME
'RANGE IN EXCEL AND USING THE EXCEL FORMULA....
'Code by Michael Red 7/26/2002
'Sample Usage:
'? baspercentile(0.75, 1567, 1634, 1700, 2100, 2330, 2400, 2550)
' 2365
Dim NthEl As Single '~ N
Dim StrtPctle As Single '~ BasePercent above
Dim IncrPctle As Single '~ Invremental Percentage ~~ 0.5
Dim DeltPctle As Single '~ Extra Percent
NumElems = UBound(MyAray) + 1
NthEl = (NumElems - 1) * (Pctl) + 1
If (NthEl = Int(NthEl)) Then
basPercentile = MyAray(NthEl)
Else
StrtPctle = MyAray(Int(NthEl - 1))
IncrPctle = (NthEl - Int(NthEl))
DeltPctle = (MyAray(Int(NthEl)) - MyAray(Int(NthEl - 1)))
basPercentile = StrtPctle + (IncrPctle * DeltPctle)
End If
End Function