Quote:
|
Originally Posted by qAnand
Hi All,
In excel there is a function called PERCENTRANK, which accepts an array and a value as input.
Is there a way we can write similar function in ASP?
Regards,
Anand
|
There is no function by that name, but is is easy to write functions in asp.
What is the function to do? return the position of the value within the array? return the value / the summed values within the array?
Code:
Function PercentRank (ary, inValue)
' Your code goes here.
' assuming that it is to return the position of the value inside the array...
' note that there is no error handling, (in case the paramater ary is not an array, for instance.)
Dim N
for N = lbound(ary) to ubound(ary)
if inValue < ary(n) then
exit for
end if
Next N
PercentRank = N/ubound(ary)
End Function