Having issues with a Rank Formula. Any help is much appreciated. The formula is below.
=RANK(E2,$E$2:$E$26,0)+COUNTIF($E$2:E2,E2)-1
Moderator comment: Crossposted https://www.ozgrid.com/forum/forum/h...h-rank-formula
Having issues with a Rank Formula. Any help is much appreciated. The formula is below.
=RANK(E2,$E$2:$E$26,0)+COUNTIF($E$2:E2,E2)-1
Moderator comment: Crossposted https://www.ozgrid.com/forum/forum/h...h-rank-formula
Last edited by alansidman; 10-05-2018 at 08:21 AM.
It may help to explain what the issue is, along with providing other details and/or a sample spreadsheet. Other details could be what you're trying to accomplish, the expected result(s) for sample data, etc.
The formula you provided is a valid formula.
What's the problem?
What are you expecting, and what are you getting?
1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
2. If your question is resolved, mark it SOLVED using the thread tools
3. Click on the star if you think someone helped you
Regards
Ford
I've attached a sample. It's skipping 4 in the rank formula.
Sample.xlsx
Upon download I found what appears to be a floating point issue in the data.
Enteringin an unused area returns this array.Formula:![]()
=MATCH(E2:E26,E2:E26,0)
Those numbers (8 and 11) correspond with the $1,875.00 figures. They should both be 8s.Formula:![]()
{1;1;1;1;1;6;1;8;1;1;11;1;1;1;1;1;1;1;1;1;1;1;1;24;1}
Shadowing column E with rounded values in column F (ROUND(E2,2)) and then changing the formula in column C to reference F produced expected results.
What is strange is that restoring references in C back to column E now produced the expected returns, andthen returned the arrayFormula:![]()
=MATCH(E2:E26,E2:E26,0). In other words the floating point seemed to disappear from column E and your formula worked fine!!Formula:![]()
{1;1;1;1;1;6;1;8;1;1;8;1;1;1;1;1;1;1;1;1;1;1;1;24;1}
Please try the MATCH function at your end to confirm the differences between the $1,875.00 figures. RANK and COUNTIF seem to be evaluating them differently.
As for the evident "self correction" I have no explanations.
Last edited by FlameRetired; 10-04-2018 at 09:33 PM.
Dave
Definitely a floating point error. I put =(1875-E9) into F9, formatted as scientific, and got a result of -2.27E-13 -- not exactly 0 In F12, the results was 0.00E+0 (exactly 0). So the two 1875 values are not exactly the same, and Excel is seeing the value in E9 as slightly larger than then the value in E12.
I followed Dave's sequence (ROUND() function in column F, replace references in C to column F, then replace references to F back to E). When I changed the references to F, I got the expected results that Dave noted. However, when I reverted back to E references, the erroneous results returned.
The sample you have given has "constants" in column E, so we have no idea how these values are calculated. Obviously something in the process is susceptible to floating point error. You will need to do something with the calculation process to account for floating point error. A ROUND() function may be enough, but you will need to test that.
Originally Posted by shg
@ MrShorty
Thank you for attending to this and confirming FP. Those looked like hard numbers, but then again we've seen that before.
That leaves accounting for the missing rank 4. Tested independently COUNTIF apparently ignores the tiny differences due to floating point while RANK and RANK.EQ do not.
Floating point seems to be something Excel ... or computers are rather fickle about. LOL![]()
The root issue does seem to be the difference noted above. If 1875 is entered in E5, the results give two 4s and no 5 - other similar tests (with same or other numbers) give similar problems. Unless there's a way of fixing this by putting ROUND into the formulae themselves (which I haven't found in the few minutes I've looked at this), then I think the easiest solution will be a helper column using ROUND, as MrShorty implied above.
Formula:![]()
F2: =ROUND(E2,2)
C2: =RANK(F2,$F$2:$F$26,0)+COUNTIF($F$2:F2,F2)-1
I'm sure someone else might have a more elegant solution.
Regards,
Aardigspook
I recently started a new job so am a bit busy and may not reply quickly. Sorry - it's not personal - I will reply eventually.
If your problem is solved, please go to 'Thread Tools' above your first post and 'Mark this Thread as Solved'.
If you use commas as your decimal separator (1,23 instead of 1.23) then please replace commas with semi-colons in your formulae.
You don't need to give me rep if I helped, but a thank-you is nice.
Try this formula![]()
=RANK(E2,$E$2:$E$26,0)+0.001*COUNTIF($E$2:E2,E2)
Willem
English is not my native language sorry for errors
Please correct me if I'm completely wrong
Has everyone overcomplicated this?? It would be nice if you had told us what result were you expecting to see!!
Maybe:
1,2,3,4,5,5,5,5,5,5,etc
where the two 1875s are 3 and 4...
or
1,2,3,3,4,4,4,etc
where the are both given rank 3 and there are no missing values
or 1,2,3,3,5,5,5,etc
Here are all 3 options...
Glenn
None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks