If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > PercentRank Function

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-13-06, 08:52
qAnand qAnand is offline
Registered User
 
Join Date: Jul 2003
Posts: 70
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
Reply With Quote
  #2 (permalink)  
Old 12-14-06, 14:30
loquin loquin is offline
Super Moderator
 
Join Date: Jun 2004
Location: Arizona, USA
Posts: 1,797
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

Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On