ranking - PercentRank algorithm in VBA -
i have found answer question "how assign rank number array when ties exist" in php , (looked lilke) c++. found couple of answers excel's percentrank in language not know.
can me in vba? need calculate percentrank 12 values in access fopr report , cannot use excel. here's example of after:
per val %rank 01 80 0.82 02 74 0.45 03 88 1.00 04 60 0.00 05 86 0.91 06 68 0.18 07 64 0.09 08 78 0.64 09 76 0.55 10 72 0.27 11 78 0.64 12 72 0.27
note period 08 , 11 value same. period 10 , 12. read somewhere when there ties function must calculate average of somesort.
would please function written in vba?
thanks bunch.
d. lamarche
ties should produce same percentage rank, example shows. if x number not in array, have extrapolate. if you're assured x in array, can simplify this
public function prank(vaarray variant, x variant) double dim llower long dim lhigher long dim long = lbound(vaarray, 1) ubound(vaarray, 1) if vaarray(i, 1) < x llower = llower + 1 elseif vaarray(i, 1) > x lhigher = lhigher + 1 end if next prank = llower / (llower + lhigher) end function
if pass x values not in vaarray, produce wrong result. also, assumes you're passing 2 dimensional array (like excel column be), may need adjust that.
Comments
Post a Comment