monkeylizard
MIS
I am having a problem counting unique records.
I want to count the number of unique Record#'s by the Flag value.
In this case, I want to know that I have 2 distinct Records where the Flag is Y and 1 where the flag is N
I have two formulas in a group header that is grouped by the RecordNum as follows:
When I do a distinct count of Formula1 and Formula2 in a group header above the record number (actually the User name) I am getting the count +1. In the example data, I get 3 and 2 respectively instead of 2 and 1.
This only happens to Formula 1 if there are N records, and to Formula 2 if there are Y records. If there are no N records (the usual case), then a Distinct Count of Formula 1 yields the proper result. It only reports one extra if there are also 'N' records. Regardless of the number of 'N' records, if there is at least one 'N' then Formula1(the one that counts the distinct 'Y') is always 1 too high. And vise-verse.
I am assuming that when it reads through Crystal is tossing a <NULL> value into the list for the formula when it hits a record that doesn't match its criteria.
I can't just subtract 1 from the Distinct Count, because both are right as long as the other Flag value doesn't exist for the user.
Any advice on this?
Monkeylizard
Sometimes just a few hours of trial and error debugging can save minutes of reading manuals.
I want to count the number of unique Record#'s by the Flag value.
Code:
Sample of Data
RecordNum SequenceNum Flag User
100 1 Y Bob
100 2 Y Bob
100 3 Y Bob
200 1 N Bob
300 1 Y Bob
300 2 Y Bob
300 3 Y Bob
300 4 Y Bob
In this case, I want to know that I have 2 distinct Records where the Flag is Y and 1 where the flag is N
I have two formulas in a group header that is grouped by the RecordNum as follows:
Code:
(Formula 1)
If FLAG = Y and Then {RecordNum}
(Formula 2)
If Flag <> Y Then {RecordNum}
When I do a distinct count of Formula1 and Formula2 in a group header above the record number (actually the User name) I am getting the count +1. In the example data, I get 3 and 2 respectively instead of 2 and 1.
This only happens to Formula 1 if there are N records, and to Formula 2 if there are Y records. If there are no N records (the usual case), then a Distinct Count of Formula 1 yields the proper result. It only reports one extra if there are also 'N' records. Regardless of the number of 'N' records, if there is at least one 'N' then Formula1(the one that counts the distinct 'Y') is always 1 too high. And vise-verse.
I am assuming that when it reads through Crystal is tossing a <NULL> value into the list for the formula when it hits a record that doesn't match its criteria.
I can't just subtract 1 from the Distinct Count, because both are right as long as the other Flag value doesn't exist for the user.
Any advice on this?
Monkeylizard
Sometimes just a few hours of trial and error debugging can save minutes of reading manuals.