look up multiple values and counts to decide cell value

dappy

Board Regular
Joined
Apr 23, 2018
Messages
124
Office Version
  1. 2013
Platform
  1. Windows
Hi,

this is what i have in col R

=IF(J129=4,1,IF(COUNTIFS(A:A,A129,B:B,"<"&B129)<D129,"1","3"))

So this works fine if the the value in column J is 4, not a problem. but its the value in column B that's causing an issue and i'm totally stuck

Capture.JPG


if Col J is 4 then Col R will equal 1
if Col J is not 4 and the second number in b for that corridor is higher then i get 3 which is cool. the problem is if the value in J is 4 and the value in B is higher than the other corridor value in B then in R its 1 and not 3.

Confusing i know but is any egghead out there that can help?
 
In that case you are going to have to explain exactly what the rules are.
 
Upvote 0

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
So sorry about this.

column D is the amount of Value "1"s that must be in Column R. with J=4 always being one of them followed by the remaining using the lowest first in column B. all others are value 3.

I really hope this helps
 
Upvote 0
speaking of Column R

so if Column D=1 then it is only the row with J=4 where R=1, all others are R=3

if column D=2 then its the row with J=4 plus the row with the lowest value in B where R=1, all others are R=3

if column D =3 then its the row with J=4 plus the 2 rows with the lowest values rows B where R=1, all others are R=3
 
Upvote 0
Ok, how about
+Fluff New.xlsm
ABCDEFGHIJKLMNOPQRS
1Corridor0Occreq$dn$operationpreferredBcchMarkchannel0Typechannel1Typechannel2Typechannel3Typechannel4Typechannel5Typechannel6Typechannel7TypeadminStateExpexted
2Corridor1132Corridor1_1update00000000013
3Corridor1232Corridor1_2update14300000011
4Corridor1332Corridor1_3update10300000033
5Corridor2621Corridor2_6update00000000033
6Corridor2721Corridor2_7update04000000011
7Corridor3952Corridor3_9update10300000033
8Corridor3752Corridor3_7update14300000011
9Corridor3852Corridor3_8update00000000033
10Corridor3652Corridor3_6update10300000033
11Corridor3252Corridor3_2update03000000011
12Corridor4173Corridor4_1update13300000011
13Corridor4273Corridor4_2update03000000011
14Corridor4373Corridor4_3update13300000033
15Corridor4473Corridor4_4update03000000033
16Corridor4573Corridor4_5update13300000033
17Corridor4673Corridor4_6update04000000011
18Corridor41073Corridor4_10update03000000033
Main
Cell Formulas
RangeFormula
R2:R18R2=IF(J2=4,1,IF(COUNTIFS(A:A,A2,B:B,"<"&B2)<D2-1,1,3))
 
Upvote 0
I bow to your massive brain, seriously you're amazing. thank you so much, you're a star! that works perfectly.

Thank you again. I'm humbled by how generous you are with your time.
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0
Hello again,

I jumped the gun, i still cant get the results correct all the time in column R. Would you mind having another look for me please? I thought all was well but it seems quite random

mr_excel.xlsm
ABCDEFGHIJKLMNOPQRS
1corridor0occredif$dn$operationpreferredBcchMarkchannel0Typechannel1Typechannel2Typechannel3Typechannel4Typechannel5Typechannel6Typechannel7TypeadminStateExpected
2Corridor11211Corridor1_1update14300000011
3Corridor12211Corridor1_2update03000000033
4Corridor25431Corridor2_5update14300000011
5Corridor26431Corridor2_6update00000000011
6Corridor210431Corridor2_10update00000000033
7Corridor29431Corridor2_9update10300000031
8Corridor41541Corridor4_1update10300000011
9Corridor42541Corridor4_2update03000000011
10Corridor45541Corridor4_5update14300000011
11Corridor46541Corridor4_6update00000000031
12Corridor410541Corridor4_10update00000000033
13Corridor811743Corridor8_11update10300000033
14Corridor81743Corridor8_1update10300000011
15Corridor82743Corridor8_2update00000000011
16Corridor810743Corridor8_10update00000000033
17Corridor89743Corridor8_9update10300000033
18Corridor83743Corridor8_3update14300000011
19Corridor84743Corridor8_4update00000000031
Network DATA+check_test
Cell Formulas
RangeFormula
G2:G19G2=A2&"_"&B2
H2:H19H2="update"
I2:I19I2=IF(Network_DATA!$A2>0,Network_DATA!C2,"")
J18:J19,J15:J16,J9:J12,J2:J6J2=IF(Network_DATA!$D2=4,4,IF(Network_DATA!$D2=3,3,IF(Network_DATA!$D2=2,0,IF(Network_DATA!$D2=0,0,(IF(Network_DATA!$D2=9,0))))))
B14:B17,B4:B12B4=VALUE(MID(Network_DATA!$A4,SEARCH("TRX-",Network_DATA!$A4)+4,SEARCH("/trx",Network_DATA!$A4)-3))
K2:K19K2=IF(Network_DATA!$E2=3,3,0)
C2:C19C2=COUNTIF(A:A,A2)
E2:E19E2=C2-D2
R2:R19R2=IF(J2=4,1,IF(COUNTIFS(A:A,A2,B:B,"<"&B2)<D2-1,1,3))
 
Upvote 0
How about
=IF(J2=4,1,IF(COUNTIFS(A:A,A2,B:B,"<"&B2)<=D2-1,1,3))
 
Upvote 0
perfect, almost :D its the issue where the value in Col B with a value of 4 in column J is higher than others for the same corridor. corridor11, 20 and 7 have the issue

mr_excel.xlsm
ABCDEFGHIJKLMNOPQRS
1corridor0occredif$dn$operationpreferredBcchMarkchannel0Typechannel1Typechannel2Typechannel3Typechannel4Typechannel5Typechannel6Typechannel7TypeadminStateExpected
2Corridor11211Corridor1_1update14300000011
3Corridor12211Corridor1_2update03000000033
4Corridor25431Corridor2_5update14300000011
5Corridor26431Corridor2_6update00000000011
6Corridor210431Corridor2_10update00000000033
7Corridor29431Corridor2_9update10300000011
8Corridor41541Corridor4_1update10300000011
9Corridor42541Corridor4_2update03000000011
10Corridor45541Corridor4_5update14300000011
11Corridor46541Corridor4_6update00000000011
12Corridor410541Corridor4_10update00000000033
13Corridor811743Corridor8_11update10300000033
14Corridor81743Corridor8_1update10300000011
15Corridor82743Corridor8_2update00000000011
16Corridor810743Corridor8_10update00000000033
17Corridor89743Corridor8_9update10300000033
18Corridor83743Corridor8_3update14300000011
19Corridor84743Corridor8_4update00000000011
20Corridor1110211Corridor11_10update14300000011
21Corridor119211Corridor11_9update03000000013
22Corridor75523Corridor7_5update10300000033
23Corridor76523Corridor7_6update04000000011
24Corridor71523Corridor7_1update10300000011
25Corridor72523Corridor7_2update00000000013
26Corridor710523Corridor7_10update00000000033
27Corridor209422Corridor20_9update10300000033
28Corridor201422Corridor20_1update10300000011
29Corridor202422Corridor20_2update00000000013
30Corridor205422Corridor20_5update14300000011
Network DATA+check_test
Cell Formulas
RangeFormula
G2:G30G2=A2&"_"&B2
H2:H30H2="update"
I2:I30I2=IF(Network_DATA!$A2>0,Network_DATA!C2,"")
J29,J25:J26,J18:J19,J15:J16,J9:J12,J2:J6J2=IF(Network_DATA!$D2=4,4,IF(Network_DATA!$D2=3,3,IF(Network_DATA!$D2=2,0,IF(Network_DATA!$D2=0,0,(IF(Network_DATA!$D2=9,0))))))
B22:B30,B14:B17,B4:B12B4=VALUE(MID(Network_DATA!$A4,SEARCH("TRX-",Network_DATA!$A4)+4,SEARCH("/trx",Network_DATA!$A4)-3))
C2:C30C2=COUNTIF(A:A,A2)
E2:E30E2=C2-D2
K2:K30K2=IF(Network_DATA!$E2=3,3,0)
R2:R30R2=IF(J2=4,1,IF(COUNTIFS(A:A,A2,B:B,"<"&B2)<=D2-1,1,3))
 
Upvote 0
How about
=IF(J2=4,1,IF(COUNTIFS(A:A,A2,B:B,"<"&B2,J:J,"<>4")<D2-1,1,3))
 
Upvote 0
Solution

Forum statistics

Threads
1,216,077
Messages
6,128,684
Members
449,463
Latest member
Jojomen56

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