If we define the xpercentile as the minimum value for wich x percent of the values in the sample are lower or equal to it, then we can issue a simple xpercentile formula using the old friends Dxxx functions:
DCount("*", "tableName", "Field<=" & [Field] )
is ranking the Field, and since there is N records, N = DCount("*", "tableName"), we just need the Minimum field value for where the rank is higher or equal to x* N:
Public Function XPercentile(FName As String, _
TName As String, _
X As Double) _
As Double
XPercentile = DMin(FName, TName, _
"DCount(""*"", """ & TName & """, """ & FName & _
"<="" & [" & FName & " ]) >= " & _
X * DCount("*", TName))
End Function
Note that I assume no NULL values.
