Second highest with a condition

EinarOSies

Board Regular
Joined
Feb 15, 2021
Messages
61
Office Version
  1. 2019
Platform
  1. Windows
I am having this formula "INDEX($B$4:$B$108,MATCH(MAXIFS(N4:N108,N4:N108,">=1",N4:N108,"<=100"),$N$4:$N$108,0))" which gives me only the first indentification value in column "B" which corresponds to the maximum value in column "N" with a condition of the range from 1-to-100. Just as I said I get only the first identification value in column "B" but the maximum value are more than one(1).



Please can I get a similar formula to find the other identification values in column "B" with the maximum value in column "N" with the condition above. For example 1st ID num.,2nd ID num,............nth ID num with the same maximum value in column "N" which correspondence to column "B".



Thanks.
 
Thank you Fluff for copying this. Was there data in columns L:M? The N formula is showing empty when I copy it since it's not seeing anything in L:M. I don't think that's important though.

EinarOSies, could you show what your expected result would be? Your formula seems to be in column P, looking at the data in columns B and Q. But I'm seeing inconsistent formulas in column P. Some have a range of 1-60, some have a range of 1-100. Which is it, or does it vary in some predictable manner? Also on rows 11, 19, 28, those formulas have ="" on the end, completely changing the result of the formula.

The formula is designed to show multiple cases where 2 or more rows have the same maximum value, but looking at the table, I don't see any instances of that.

Could you say in words what you want, for example: I want P4 to be 18/1/21, and P5 to be 22/1/21 because those values are on rows 20 and 24 and the values in Q20 and Q24 are both 2.08, and 2.08 is the lowest value in column Q.
 
Upvote 0

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Was there data in columns L:M?
Yes there was, hadn't noticed that they were being referenced in col N.

KUMASI ASSEMBLY HALL ECG MONITORING SHEET.xlsx
BCDEFGLMNOPQR
1DATEDAYDAY2NIGHT….Column1Column2Column3Column4Column5Column6Column7
26AM REC.6PM REC.6PM REC.6AM REC.
3
402/01/2021Saturday6.72.792.79481.29GH₵3.91-GH₵478.50########31/03/20213.91-478.5
503/01/2021Sunday481.29475.42475.42455.87GH₵5.87GH₵19.55GH₵13.68 5.8719.55
604/01/2021Monday455.87450.01450.01431.44GH₵5.86GH₵18.57GH₵12.71 5.8618.57
705/01/2021Tuesday431.44425.58425.58404.07GH₵5.86GH₵21.51GH₵15.65 5.8621.51
806/01/2021Wednesday404.07389.21389.21373.77GH₵14.86GH₵15.44GH₵0.57 14.8615.44
907/01/2021Thursday373.77368.89368.89349.34GH₵4.88GH₵19.55GH₵14.67 4.8819.55
1008/01/2021Friday349.34352.5352.5322.95-GH₵3.16GH₵29.55GH₵32.71 -3.1629.55
1109/01/2021Saturday322.95318.06318.06299.49GH₵4.89GH₵18.57GH₵13.68TRUE4.8918.57
1210/01/2021Sunday299.49293.63293.63274.08GH₵5.86GH₵19.55GH₵13.695.8619.55
1311/01/2021Monday274.08268.21268.21251.6GH₵5.87GH₵16.61GH₵10.7402/03/20215.8716.61
1412/01/2021Tuesday251.6246.65246.65225.85GH₵4.95GH₵20.80GH₵15.85 4.9520.8
1513/01/2021Wednesday225.85217.53217.53196.72GH₵8.32GH₵20.81GH₵12.49 8.3220.81
1614/01/2021Thursday196.72189.44189.44168.64GH₵7.28GH₵20.80GH₵13.52 7.2820.8
1715/01/2021Friday168.64162.4162.4148.6GH₵6.24GH₵13.80GH₵7.56 6.2413.8
1816/01/2021Saturday148.6136.4136.4115.6GH₵12.20GH₵20.80GH₵8.60 12.220.8
1917/01/2021Sunday115.6109.35109.3587.51GH₵6.25GH₵21.84GH₵15.59TRUE6.2521.84
2018/01/2021Monday87.5185.4385.4363.59GH₵2.08GH₵21.84GH₵19.762.0821.84
2119/01/2021Tuesday63.5957.3557.3539.67GH₵6.24GH₵17.68GH₵11.4425/01/20216.2417.68
2220/01/2021Wednesday39.6734.4734.4714.71GH₵5.20GH₵19.76GH₵14.56 5.219.76
2321/01/2021Thursday14.715.345.34500.14GH₵9.37-GH₵494.80######## 9.37-494.8
2422/01/2021Friday500.14498.06498.06477.26GH₵2.08GH₵20.80GH₵18.72 2.0820.8
2523/01/2021Saturday477.26469.98469.98451.26GH₵7.28GH₵18.72GH₵11.44 7.2818.72
2624/01/2021Sunday451.26445.02445.02419.25GH₵6.24GH₵25.77GH₵19.53 6.2425.77
2725/01/2021Monday419.25409.4409.4376.59GH₵9.85GH₵32.81GH₵22.96 9.8532.81
2826/01/2021Tuesday376.59366.72366.72333.9GH₵9.87GH₵32.82GH₵22.95TRUE9.8732.82
2927/01/2021Wednesday333.9320.77320.77286.3GH₵13.13GH₵34.47GH₵21.3413.1334.47
3028/01/2021Thursday286.3274.81274.81241.98GH₵11.49GH₵32.83GH₵21.3403/03/202111.4932.83
3129/01/2021Friday241.98232.14232.14199.31GH₵9.84GH₵32.83GH₵22.99 9.8432.83
3230/01/2021Saturday199.31191.14191.14161.56GH₵8.17GH₵29.58GH₵21.41 8.1729.58
3331/01/2021Sunday161.56151.71151.71114.77GH₵9.85GH₵36.94GH₵27.09 9.8536.94
3401/02/2021Monday114.77104.76104.7689.36GH₵10.01GH₵15.40GH₵5.39 10.0115.4
3502/02/2021Tuesday89.3683.483.463.94GH₵5.96GH₵19.46GH₵13.50 5.9619.46
3603/02/2021Wednesday63.9457.157.138.98GH₵6.84GH₵18.12GH₵11.28TRUE6.8418.12
3704/02/2021Thursday38.9831.6931.6913.12GH₵7.29GH₵18.57GH₵11.287.2918.57
3805/02/2021Friday13.126.286.28485.75GH₵6.84-GH₵479.47########6.84-479.47
3906/02/2021Saturday485.75479.89479.89461.32GH₵5.86GH₵18.57GH₵12.715.8618.57
4007/02/2021Sunday461.3252.5252.52433.95GH₵408.80-GH₵381.43########408.8-381.43
4108/02/2021Monday433.95426.13426.13404.63GH₵7.82GH₵21.50GH₵13.687.8221.5
4209/02/2021Tuesday404.63398.78398.78378.24GH₵5.85GH₵20.54GH₵14.685.8520.54
4310/02/2021Wednesday378.24373.35373.35352.83GH₵4.89GH₵20.52GH₵15.634.8920.52
4411/02/2021Thursday352.83346.96346.96327.16GH₵5.87GH₵19.80GH₵13.925.8719.8
4512/02/2021Friday327.16319.88319.88314.53GH₵7.28GH₵5.35-GH₵1.937.285.35
4613/02/2021Saturday314.53288.68288.68267.88GH₵25.85GH₵20.80-GH₵5.0425.8520.8
4714/02/2021Sunday267.88262.68262.68240.83GH₵5.20GH₵21.85GH₵16.655.221.85
4815/02/2021Monday240.83233.55233.55216.92GH₵7.28GH₵16.63GH₵9.357.2816.63
4916/02/2021Tuesday216.92207.55207.55186.75GH₵9.37GH₵20.80GH₵11.439.3720.8
5017/02/2021Wednesday186.75180.51180.51162.83GH₵6.24GH₵17.68GH₵11.446.2417.68
DATA RECORDS
Cell Formulas
RangeFormula
F4:F50F4=E4
G4:G50G4=D5
L4:L50L4=SUM(D4-E4)
M4:M50M4=SUM(F4-G4)
N4:N50N4=ROUNDDOWN(SUM(M4-L4),2)
Q4:Q50Q4=SUM(D4-E4)
R4:R50R4=SUM(F4-G4)
P4:P8,P10P4=IFERROR(INDEX($B$4:$B$108,AGGREGATE(15,6,ROW($B$4:$B$108)/($Q$4:$Q$108=MAXIFS($Q$4:$Q$108,$Q$4:$Q$108,">=1",$Q$4:$Q$108,"<=60")),ROWS(P$4:P4))),"")
P9P9=IFERROR(INDEX($B$4:$B$108,AGGREGATE(15,6,ROW($B$4:$B$108)/($Q$4:$Q$108=MAXIFS($Q$4:$Q$108,$Q$4:$Q$108,">=1",$Q$4:$Q$108,"<=100")),ROWS(P$4:P9))),"")
P11P11=IFERROR(INDEX($B$4:$B$108,AGGREGATE(15,6,ROW($B$4:$B$108)/($Q$4:$Q$108=MAXIFS($Q$4:$Q$108,$Q$4:$Q$108,">=1",$Q$4:$Q$108,"<=60")),ROWS(P$4:P5))),"")=""
P13:P18P13=IFERROR(INDEX($B$4:$B$108,AGGREGATE(15,6,ROW($B$4:$B$108)/($R$4:$R$108=MAXIFS($R$4:$R$108,$R$4:$R$108,">=1",$R$4:$R$108,"<=60")),ROWS(P$13:P13))),"")
P19P19=IFERROR(INDEX($B$4:$B$108,AGGREGATE(15,6,ROW($B$4:$B$108)/($R$4:$R$108=MAXIFS($R$4:$R$108,$R$4:$R$108,">=1",$R$4:$R$108,"<=60")),ROWS(P$13:P19))),"")=""
P21:P25,P27P21=IFERROR(INDEX($B$4:$B$108,AGGREGATE(15,6,ROW($B$4:$B$108)/($Q$4:$Q$108=MINIFS($Q$4:$Q$108,$Q$4:$Q$108,">=1",$Q$4:$Q$108,"<=60")),ROWS(P$21:P21))),"")
P26P26=IFERROR(INDEX($B$4:$B$108,AGGREGATE(15,6,ROW($B$4:$B$108)/($Q$4:$Q$108=MINIFS($Q$4:$Q$108,$Q$4:$Q$108,">=1",$Q$4:$Q$108,"<=100")),ROWS(P$21:P26))),"")
P28P28=IFERROR(INDEX($B$4:$B$108,AGGREGATE(15,6,ROW($B$4:$B$108)/($Q$4:$Q$108=MINIFS($Q$4:$Q$108,$Q$4:$Q$108,">=1",$Q$4:$Q$108,"<=60")),ROWS(P$21:P22))),"")=""
P30:P35P30=IFERROR(INDEX($B$4:$B$108,AGGREGATE(15,6,ROW($B$4:$B$108)/($R$4:$R$108=MINIFS($R$4:$R$108,$R$4:$R$108,">=1",$R$4:$R$108,"<=60")),ROWS(P$30:P30))),"")
P36P36=IFERROR(INDEX($B$4:$B$108,AGGREGATE(15,6,ROW($B$4:$B$108)/($R$4:$R$108=MINIFS($R$4:$R$108,$R$4:$R$108,">=1",$R$4:$R$108,"<=60")),ROWS(P$30:P31))),"")=""
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B33:J33Expression="GH₵ "&TEXT(AGGREGATE(14,6,MID($J$4:$J$108,5,20)/((MID($J$4:$J$108,5,20)+0>=1)*(MID($J$4:$J$108,5,20)+0<=60)),1),"###.00")=B33textNO
B33:J33Expression="GH₵ "&TEXT(AGGREGATE(14,6,MID($J$4:$J$108,5,20)/((MID($J$4:$J$108,5,20)+0>=1)*(MID($J$4:$J$108,5,20)+0<=60)),1),"###.00")=B33textNO
 
Upvote 0

Forum statistics

Threads
1,216,028
Messages
6,128,395
Members
449,446
Latest member
CodeCybear

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