help with counting total items with a selected group of rows

Novaember

Registered User.
Local time
Today, 08:36
Joined
Nov 3, 2009
Messages
33
Hello

I have a query where I select certain rows based on User, Department, Year and Month.

that gives me a list of rows for the specific user I want to look at

Then I want to count items within these rows based on what is in the fields.

For example Sum(IIF([CorrectProduct]="YES",1,0)+IIF([RemarkCodeCorrect] = "YES",1,0))
I can count the items easily unless my criteria returns no rows based on the initial criteria. I want the query to display a ZERO and it returns nothing.

I've tried Nz(Sum(IIF([CorrectProduct]="YES",1,0)+IIF([RemarkCodeCorrect] = "YES",1,0)),0) but that doesn't come out right.

I've also tried Count(IIF([CorrectProduct]="YES",1,0)+IIF([RemarkCodeCorrect] = "YES",1,0))
again with no luck. I know it is something really simple but I can't wrap my brain around it today.
Any help is greately appreciated.
:)
 
It is possible that [CorrectProduct] and [RemarkCodeCorrect] have Yes/No/Null values. If they have Null values, [CorrectProduct]="Yes" will not work for those rows. So add another 'and' clause that checks if the field is not null also.
So your expression will look like,
Sum(IIF([CorrectProduct]="YES" and [CorrectProduct] is not null,1,0)+IIF([RemarkCodeCorrect] = "YES" and [RemarkCodeCorrect] is not null,1,0))

This should work.
 

Users who are viewing this thread

Back
Top Bottom