Solved Count iif in a query (1 Viewer)

nirmal

Member
Local time
Today, 22:31
Joined
Feb 27, 2020
Messages
82
Sir I have a Place_tbl with Field name Place e.g
A, L, M, N
B, L, M, N
C, L, P, N
D, I, Q, O
E, L, M, N
F, J, H, X
G, L, M, N

for working out the count of
Only M
Only N
Not Like N
Not like M but like N
for which expression are

Count(IIf(([Place_tbl].[Place]) Like "*N*",1,Null)) AS WithinN
Count(IIf(([Place_tbl].[Place]) Not Like "*N*",1,Null)) AS OutsideN
Count(IIf(([Place_tbl].[Place]) Like "*M*",1,Null)) AS WithinM

Can we make a expression to where we can count place with criteria
Like M and N
Not Like M But like N

Please guide
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:01
Joined
May 7, 2009
Messages
19,245
1. Like M and N

Count(IIf(([Place_tbl].[Place]) Like "*N*" OR ([Place_tbl].[Place]) Like "*M*",1,Null)) AS WithinNM

2. Not Like M But like N

Count(IIf(([Place_tbl].[Place]) Like "*N*" AND ([Place_tbl].[Place]) NOT Like "*M*",1,Null)) AS WithinNM
 

nirmal

Member
Local time
Today, 22:31
Joined
Feb 27, 2020
Messages
82
1. Like M and N

Count(IIf(([Place_tbl].[Place]) Like "*N*" OR ([Place_tbl].[Place]) Like "*M*",1,Null)) AS WithinNM

2. Not Like M But like N

Count(IIf(([Place_tbl].[Place]) Like "*N*" AND ([Place_tbl].[Place]) NOT Like "*M*",1,Null)) AS WithinNM
Thank You Sir for Your help
Getting all desired results
 

Users who are viewing this thread

Top Bottom