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?
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Maybe just
=IF(COUNTIFS(A:A,A129,B:B,"<"&B129)<D129,1,3)
 
Upvote 0
Thanks again for replying,

problem is that we may have 3 or 4 corridor1's or corridor2's.

If there are 4 corridor1's and column c is showing, say, 2 then 2 of the column R's should show value 3, and the other showing value 1. this works fine unless the value in column B with a "4" in column J is higher than the others for corridor1.
 
Upvote 0
Can you please post some sample data, including expected results, using the XL2BB add-in.
 
Upvote 0
Of course

TRX_Reduction_Test_06072020.xlsm
ABCDEFGHIJKLMNOPQRS
1CorridorcamOccreq$dn$operationpreferredBcchMarkchannel0Typechannel1Typechannel2Typechannel3Typechannel4Typechannel5Typechannel6Typechannel7TypeadminStateExpexted
2Corridor1131Corridor1_1update00000000013
3Corridor1231Corridor1_2update14300000011
4Corridor1331Corridor1_3update10300000033
5Corridor2621Corridor2_6update00000000013
6Corridor2721Corridor2_7update04000000011
7Corridor3942Corridor3_9update10300000033
8Corridor3742Corridor3_7update14300000011
9Corridor3842Corridor3_8update00000000033
10Corridor3642Corridor3_6update10300000011
Network DATA+check_test
Cell Formulas
RangeFormula
G2:G10G2=A2&"_"&B2
H2:H10H2="update"
I2:I10I2=IF(Network_DATA!$A84>0,Network_DATA!C84,"")
J8:J9,J2:J3J2=IF(Network_DATA!$D84=4,4,IF(Network_DATA!$D84=3,3,IF(Network_DATA!$D84=2,0,IF(Network_DATA!$D84=0,0,(IF(Network_DATA!$D84=9,0))))))
B7:B9,B5,B2:B3B2=VALUE(MID(Network_DATA!$A84,SEARCH("TRX-",Network_DATA!$A84)+4,SEARCH("/trx",Network_DATA!$A84)-3))
C2:C10C2=COUNTIF(A:A,A2)
K2:K10K2=IF(Network_DATA!$E84=3,3,0)
R2:R10R2=IF(J2=4,1,IF(COUNTIFS(A:A,A2,B:B,"<"&B2)<D2,"1","3"))
 
Upvote 0
its only column R that i have issues with
 
Upvote 0
Sorry, but I'm now totally lost, why would you expect 3 in rows 2 & 5?
J is not 4 & there are no lower numbers in B for that corridor.
 
Upvote 0
I apologise, clearly i cant describe what i need.

Its based on the column D. if Column D = 1, then all but the row with 4 in Column J will be 3. its a count of what needs to be removed. 3 being remove, 1 being leave.
 
Upvote 0
Maybe
=IF(J2=4,1,IF(OR(D2=1,COUNTIFS(A:A,A2,B:B,">"&B2)<D2),3,1))
 
Upvote 0
Close to perfect but, seems doesnt work for all instances.

TRX_Reduction_Test_06072020.xlsm
ABCDEFGHIJKLMNOPQRS
1CorridorcamOccreq$dn$operationpreferredBcchMarkchannel0Typechannel1Typechannel2Typechannel3Typechannel4Typechannel5Typechannel6Typechannel7TypeadminStateExpexted
2Corridor1132Corridor1_1update00000000013
3Corridor1232Corridor1_2update14300000011
4Corridor1332Corridor1_3update10300000033
5Corridor2621Corridor2_6update00000000033
6Corridor2721Corridor2_7update04000000011
7Corridor3952Corridor3_9update10300000033
8Corridor3752Corridor3_7update14300000011
9Corridor3852Corridor3_8update00000000033
10Corridor3652Corridor3_6update10300000013
11Corridor3252Corridor3_2update03000000011
12Corridor4173Corridor4_1update13300000011
13Corridor4273Corridor4_2update03000000011
14Corridor4373Corridor4_3update13300000013
15Corridor4473Corridor4_4update03000000013
16Corridor4573Corridor4_5update13300000033
17Corridor4673Corridor4_6update04000000011
18Corridor41073Corridor4_10update03000000033
Network DATA+check_test
Cell Formulas
RangeFormula
B7:B9,B5,B2:B3B2=VALUE(MID(Network_DATA!$A84,SEARCH("TRX-",Network_DATA!$A84)+4,SEARCH("/trx",Network_DATA!$A84)-3))
J8:J9,J2:J3J2=IF(Network_DATA!$D84=4,4,IF(Network_DATA!$D84=3,3,IF(Network_DATA!$D84=2,0,IF(Network_DATA!$D84=0,0,(IF(Network_DATA!$D84=9,0))))))
B11,B16:B18B11=VALUE(MID(Network_DATA!$A107,SEARCH("TRX-",Network_DATA!$A107)+4,SEARCH("/trx",Network_DATA!$A107)-3))
J11,J18,J13J11=IF(Network_DATA!$D107=4,4,IF(Network_DATA!$D107=3,3,IF(Network_DATA!$D107=2,0,IF(Network_DATA!$D107=0,0,(IF(Network_DATA!$D107=9,0))))))
C2:C18C2=COUNTIF(A:A,A2)
G2:G18G2=A2&"_"&B2
R2:R18R2=IF(J2=4,1,IF(OR(D2=1,COUNTIFS(A:A,A2,B:B,">"&B2)<D2),3,1))
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,865
Members
449,052
Latest member
Fuddy_Duddy

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