Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2003
    Posts
    70

    Unanswered: PercentRank Function

    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

  2. #2
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    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
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •