Counting specific entries based on various conditions

Newbienew

Active Member
Joined
Mar 17, 2017
Messages
376
Office Version
  1. 2016
Platform
  1. Windows
Good Day,

This is hard to explain but, I have a formulas (D177 and down) that I have been using for some time to count specific conditional entries. The current formula already counts for "QUAL" and "c/O." C/O is no longer needed but we would like to keep the function of what the formula does for "QUAL." I am looking to modify the formula to account for any entries of the text QUAL in the V4:v145 range, as well as count any entries of the text of ENL or AFF if any odd row in the B4:b145 column has a date in it if there is a name in the adjacent odd number row a4:A145.

Bottom Line Up Front (BLUF) I need to count for Qual in the range of v4:v145 based on if there is a name the second row of the combined row of a4:a145 and if there is a date in adjacent cell in b4:b145, and it needs to count for the code in e4:e145. So if name one is entered in A175, The combined row of 72 73 would be counted as 1 under RI and the same would go for combined rows 82 83 for it to be counted a PDC

Sorry if it seems I explained it twice, now sure if it makes sense.

Due to 3000 cell limit I did to xl2bb


working AL example.xlsx
ABCDEFGHIJKLMNOPQRSTUV
2
3
4C/OPDCENL
5Name1C/O
6C/OPDCENL
7Name4C/O
8C/OPH
9Name3C/O
10C/OPH
11Name4C/O
12C/ORL
13Name4C/O
14C/OPDCENL
15Name2C/O
16C/ORR
17Name4C/O
18C/OPDC
19Name2C/O
20C/OSN
21Name2C/O
22C/OPH
23Name3C/O
24C/ORR
25Name2C/O
26C/ORI
27Name1C/O
28C/OPHENL
29Name1C/O
30C/OPDC
31Name1C/O
32C/OSN
33Name1C/O
34C/ORRDECL
35Name3C/O
36C/OPDC
37Name4C/O
38C/ORR
39Name4C/O
40C/ORR
41Name2C/O
42C/OPH
43Name2C/O
44C/ORR
45Name4C/O
46C/ORR
47Name4C/O
48C/ORR
49Name1C/O
50C/OPDC
51Name3C/O
52C/OPDC
53Name1C/O
54C/OPH
55Name3C/O
56C/OPDCqual
57Name1C/O
58C/OSN
59Name1C/O
60C/ORL
61Name3C/O
62C/OPHdecl
63Name3C/O
64C/OPH
65Name1
66C/OPH
67Name2C/O
68C/OPH
69Name1
70C/ORA
71Name3C/O
72RIQUAL
73Name17-Dec-23
744-Dec-23PHQUAL
75Name37-Dec-23
765-Dec-23PH
77Name26-Dec-23
7812-Dec-23PDC
79Name314-Dec-23
8018-Dec-23PH
81Name3
82pdcENL
83Name119-Dec-23
84
85
86
87
Sheet1







working AL example.xlsx
ABCDEF
176Name1APPINTQUAL'EDPHYSENL/AFF
177PH   1
178RN 
179RL 
180TOTAL00001
181
182RA    
183RC 
184RD 
185RI11
186RS 
187RR 
188TOTAL01100
189
190SN    
191OA 
192TOTAL00000
193
194PDC 11 2
195TOTAL00001
196
197WI     
198TOTAL00000
199-
Sheet1
Cell Formulas
RangeFormula
B177,B194,B190,B182B177=IF(SUMPRODUCT(--(MOD(ROW($A$4:$A$147),2)=0),--ISNUMBER((""&$B$4:$B$147)+0),--($E$4:$E$147=$A177),--($A$5:$A$148=$A$176))=0,"",SUMPRODUCT(--(MOD(ROW($A$4:$A$147),2)=0),--ISNUMBER((""&$B$4:$B$147)+0),--($E$4:$E$147=$A177),--($A$5:$A$148=$A$176)))
C177,C197,C194,C190,C182C177=IF(SUMPRODUCT(--(MOD(ROW($A$4:$A$147),2)=1),--ISNUMBER((""&$B$4:$B$147)+0),--($E$3:$E$146=$A177),--($A$4:$A$147=$A$176))=0,"",SUMPRODUCT(--(MOD(ROW($A$4:$A$147),2)=1),--ISNUMBER((""&$B$4:$B$147)+0),--($E$3:$E$146=$A177),--($A$4:$A$147=$A$176)))
F177,F197,F194,F190,F182F177=IF(SUMPRODUCT(--(IF(Name=$A$176,$E$3:$E$146)=$A177)*--(IF(Name=$A$176,$V$3:$V$146)="ENL")+--(IF(Name=$A$176,$E$3:$E$146)=$A177)*--(IF(Name=$A$176,$V$3:$V$146)="AFF"))=0,"",SUMPRODUCT(--(IF(Name=$A$176,$E$3:$E$146)=$A177)*--(IF(Name=$A$176,$V$3:$V$146)="ENL")+--(IF(Name=$A$176,$E$3:$E$146)=$A177)*--(IF(Name=$A$176,$V$3:$V$146)="AFF")))
D197,D194,D190:D191,D182:D187,D177:D179D177=IF(SUMPRODUCT(--(IF(Name=$A$176,$E$3:$E$146)=$A177)*--(IF(Name=$A$176,$V$3:$V$146)="C/O")+--(IF(Name=$A$176,$E$3:$E$146)=$A177)*--(IF(Name=$A$176,$V$3:$V$146)="QUAL"))=0,"",SUMPRODUCT(--(IF(Name=$A$176,$E$3:$E$146)=$A177)*--(IF(Name=$A$176,$V$3:$V$146)="C/O")+--(IF(Name=$A$176,$E$3:$E$146)=$A177)*--(IF(Name=$A$176,$V$3:$V$146)="QUAL")))
E194,E197E194=IF(SUMPRODUCT(--(IF(Name=$A$176,$E$3:$E$146)=$A194)*--(IF(Name=$A$176,$O$3:$O$146)="MEPS"))=0,"",SUMPRODUCT(--(IF(Name=$A$176,$E$3:$E$146)=$A194)*--(IF(Name=$A$176,$O$3:$O$146)="MEPS")))
B197B197=IF(SUMPRODUCT(--(MOD(ROW($A$4:$A$147),2)=0),--ISNUMBER((""&$B$4:$B$147)+0),--($E$4:$E$147=$A197),--($A$5:$A$148=$A$176))>0,"WALK-INS ARE NOT APPT","")
Press CTRL+SHIFT+ENTER to enter array formulas.
 
The cell format formula is amazing. I would have never thought of something like that. Thank you for that nugget.

No worries about the misunderstanding. It's an everyday thing for me at work.

Thank you greatly for the catch of the meps. I did not add it on the example, but on the original, the formula is the same as when we started with the -- and all.

B197, is working as intended. If the code is WI, then there is no APP date, only an INV.

I came to get the formula rewritten for the QUAL column and got so much more. You have simplified all formulas to the point of not having to use CSE, and it is easier to type out as well. I am humbly grateful for your time, patience, and help on the whole thing, honestly.
 
Upvote 0

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Thanks for the update...glad to hear the formulas and formatting are working.
Two things:
  1. I meant to mention this earlier...there is nothing wrong with how you originally used the double unary operator (the "--" used to coerce 1's and 0's from TRUE's and FALSE's). My comment about that was meant to suggest that you can achieve the same effect by simply multiplying the TRUE/FALSE array using the * operator...and some may find that doing so is more intuitive (and it leads to a slightly shorter formula).
  2. The WI formula uses this term...ISNUMBER($B$4:$B$147)...which means a date must exist on the even row of the even-odd row pair as one of the conditions that leads to the "walk-in" message. You mentioned when WI is the code, there is no APP date, only an INV date. I believe you mentioned in post #7 that the upper date (i.e., the even row of the pair) is an APP date, while the lower date (the odd row of the pair) is an INV date. Therefore, I believe the ISNUMBER range would be $B$5:$B$148 rather than $B$4:$B$147...you mentioned the formula is working as intended, so I must be missing something?
 
Upvote 0
I like simple, as life is less complicated.

So I just ran into a snag. We just recently put this in to google sheets and the QUAL and the ENL columns seem to not identify what is in the { } brackets. It will only pick up what ever the first one is. Is there a reason? and is there a way to adjust for that.

I can't stand google sheets by the way. It makes somethings extremely hard.
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,954
Members
449,096
Latest member
Anshu121

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