Counting no rows
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 1044
- Joined: Wed Sep 29, 2004 3:30 am
- Location: Nottingham, UK
- Contact:
Counting no rows
My reject counter isn't returning a count if there are no rejected rows. Ideally I'd like the reject report to say there are zero. The only way I can see of doing it is to feed in a dummy error record into a link collector prior to the aggregator, then subtract 1 from the count in a transformer after the aggregator. Seems like a lot of effort on every rejection report though. Any other suggestions?
Phil Hibbs | Capgemini
Technical Consultant
Technical Consultant
Ahhh, you need at least 1 row to generate the 0 answer. How about sending rows to the aggregator with a value and don't use a COUNT function but a SUM function? Always send a 0 value to the InvalidRows_Count link when @INROWNUM=1 (unless it's invalid) otherwise always send 1.
The problem will be that when your primary input stream is 0 rows you'll never get an output again.![Crying or Very sad :cry:](./images/smilies/icon_cry.gif)
The problem will be that when your primary input stream is 0 rows you'll never get an output again.
![Crying or Very sad :cry:](./images/smilies/icon_cry.gif)
Kenneth Bland
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
-
- Premium Member
- Posts: 1044
- Joined: Wed Sep 29, 2004 3:30 am
- Location: Nottingham, UK
- Contact:
Oh, I see. The output link has three columns:
TYPE = fixed text describing the type of record, e.g. "Purchase Orders"
REPORT = fixed text categorising the rows, e.g. "Invalid Rows"
KEY = key value of record
The aggregator passes through the first two columns and counts the last one. Implementing Ken's suggestion would replace this KEY column with a numeric value that is 1 for a rejected row, or 0 for a non-reject row which only needs to be written out once for example when @INROWNUM=1. So the constraint would be something like "svError OR @INROWNUM=1", and the derivation would be "IF svError THEN 1 ELSE 0".
TYPE = fixed text describing the type of record, e.g. "Purchase Orders"
REPORT = fixed text categorising the rows, e.g. "Invalid Rows"
KEY = key value of record
The aggregator passes through the first two columns and counts the last one. Implementing Ken's suggestion would replace this KEY column with a numeric value that is 1 for a rejected row, or 0 for a non-reject row which only needs to be written out once for example when @INROWNUM=1. So the constraint would be something like "svError OR @INROWNUM=1", and the derivation would be "IF svError THEN 1 ELSE 0".
Phil Hibbs | Capgemini
Technical Consultant
Technical Consultant
I suggested using the method of SUMming rather than COUNTing. You can send all rows to a reject inspection link and thru an aggregator. If the row is an issue, you set the value to 1. If the row is not an issue, you set the value to 0. Rather than counting explicit rows, you can sum a condition. You'll always get an output row from the Aggregator provided at least 1 row goes to it. I'm saying send the first, or all, just use SUM logic rather than COUNT.
Kenneth Bland
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle