How to generate sequence numbers within a sorted list
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 31
- Joined: Mon Jun 28, 2010 5:15 am
- Location: pune
Hopefully something similar but with better stage variable names.
FYI - this is old school stage variable usage for resetting a counter while doing group change detection. And the first variable isn't really needed but can be helpful if your 'group' consists of multiple fields. And as with all things Stage Variable, order matters as they evaluate top down.
You can simplify the group check by letting a Sort stage do that for part for you. If you've done that you'll have a new field called KeyChange that is set to True on the first entry of a group. So the code becomes:
FYI - this is old school stage variable usage for resetting a counter while doing group change detection. And the first variable isn't really needed but can be helpful if your 'group' consists of multiple fields. And as with all things Stage Variable, order matters as they evaluate top down.
Code: Select all
svCounter: If F1 = svOldF1 then svCounter+1 else 1
svOldF1 = F1
Code: Select all
svCounter: If KeyChange then 1 else svCounter+1
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers