Difference from Top Rated Value in a Range

paulfitz320

Board Regular
Joined
Jan 6, 2007
Messages
126
Office Version
  1. 365
Platform
  1. Windows
Book3
AB
1RatingWanted
289-2
3872
4872
5863
6818
77613
87514
97316
106623
116128
Sheet1


Hi,
Would appreciate a formula for the 'Wanted' column please.
It needs to return the difference between the Top Rated and Adjacent Value in the 'Rating' column.
Also the value calculated for the Highest Rated should be the difference between the Highest Rated and Second Highest Rated then converted to a minus value. Here 89 is 2 more than the next highest value in the range 87 so gets a -2
Thanks.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Try this:
2024-02-29.xlsx
ABC
1RatingWantedFormula
289-2-2
38722
48722
58633
68188
7761313
8751414
9731616
10662323
11612828
Sheet2
Cell Formulas
RangeFormula
C2:C11C2=IF(A2=LARGE($A$2:$A$11,1),LARGE($A$2:$A$11,2)-A2,LARGE($A$2:$A$11,1)-A2)
 
Upvote 0
Perhaps this:
Book1
ABC
1RatingWantedFormula
289-2-2
38722
48722
58633
68188
7761313
8751414
9731616
10662323
11612828
Sheet1
Cell Formulas
RangeFormula
C2:C11C2=LET(m,MAX($A$2:$A$11),IF(A2=m,LARGE($A$2:$A$11,2)-A2,m-A2))
 
Upvote 0
Thanks, they both worked fine.
One more thing...would it be possible to modify the formula to accommodate joint top ratings - lets say 89 was there twice, it would return -2 twice in the range. Having tried this with the solutions provided, its returning 0 for both top rated in the wanted column.
Thanks again.
 
Upvote 0
Try this formula in column D:
Book1
ABCD
1RatingWantedFormulaNew Formula
289-20-2
38920-2
487222
586333
681888
776131313
875141414
973161616
1066232323
1161282828
Sheet1
Cell Formulas
RangeFormula
C2:C11C2=LET(m,MAX($A$2:$A$11),IF(A2=m,LARGE($A$2:$A$11,2)-A2,m-A2))
D2:D11D2=IF(A2=MAX($A$2:$A$11),LARGE(UNIQUE($A$2:$A$11),2)-LARGE(UNIQUE($A$2:$A$11),1),MAX($A$2:$A$11)-A2)


Or slightly shorter:
Excel Formula:
=LET(m,MAX($A$2:$A$11),u,UNIQUE($A$2:$A$11),IF(A2=m,LARGE(u,2)-LARGE(u,1),m-A2))
 
Upvote 0
Book7
ABCDE
1GroupRatingWantedFormulaNew Formula
2Cat89-20-2
3Cat8920-2
4Cat87222
5Cat86333
6Cat81888
7Cat76131313
8Cat75141414
9Cat73161616
10Cat66232323
11Cat61282828
12Dog89-20-2
13Dog8920-2
14Dog87222
15Dog86333
16Dog81888
17Dog76131313
18Dog75141414
19Dog73161616
20Dog66232323
21Dog61282828
Sheet1
Cell Formulas
RangeFormula
D2:D21D2=LET(m,MAX($B$2:$B$11),IF(B2=m,LARGE($B$2:$B$11,2)-B2,m-B2))
E2:E21E2=IF(B2=MAX($B$2:$B$11),LARGE(UNIQUE($B$2:$B$11),2)-LARGE(UNIQUE($B$2:$B$11),1),MAX($B$2:$B$11)-B2)


Hi there,
Just wondering would it be possible to edit the formula in COL E to take account of the different Groups in Col A. The groups in COL A extend further down the sheet, so the formula would need to dynamically adjust for this.
Thanks
 
Upvote 0
Okay, see the formula in col F:
Book1
ABCDEF
1GroupRatingWantedFormulaNew FormulaNew New Formula
2Cat89-206-2
3Cat89206-2
4Cat872282
5Cat863393
6Cat8188148
7Cat7613131913
8Cat7514142014
9Cat7316162216
10Cat6623232923
11Cat6128283428
12Dog95-6-6-6-6
13Dog896066
14Dog878288
15Dog869399
16Dog811481414
17Dog7619131919
18Dog7520142020
19Dog7322162222
20Dog6629232929
21Dog4946404646
Sheet2
Cell Formulas
RangeFormula
D2:D21D2=LET(m,MAX($B$2:$B$11),IF(B2=m,LARGE($B$2:$B$11,2)-B2,m-B2))
E2:E21E2=IF(B2=MAX($B$2:$B$21),LARGE(UNIQUE($B$2:$B$21),2)-LARGE(UNIQUE($B$2:$B$21),1),MAX($B$2:$B$21)-B2)
F2:F21F2=LET(f,TAKE(FILTER($A$2:$B$21,$A$2:$A$21=A2),,-1),IF(B2=MAX(f),LARGE(UNIQUE(f),2)-LARGE(UNIQUE(f),1),MAX(f)-B2))
 
Upvote 0
Solution

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top