Hi folks,
I might have a simple question regarding transformer logic. My challenge is to determine if an error within a group occured once. If the first data in a group represents an error (marked as 1) for the first time, then the counter (AmountOfWrongGroup) should be set to 1 for the record. But if there are following erros within the group it should be set to 0.
For example:
Group-ID --- Error --- AmountOfWrongGroup
A 0 0
A 1 1
A 1 0
B 1 1
B 0 0
C 0 0
C 0 0
I tried by working with stage variables and building a search string per group, but I didn't get it work correctly
Do you have a clue? Thanks a lot!
Transformer logic: How to mark a record within a group once?
Moderators: chulett, rschirm, roy
Transformer logic: How to mark a record within a group once?
Cheers,
DS-mate
DS-mate
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Welcome aboard.
The trick is to set the stage variable to itself when you don't need to change it. For example, initialize svTest to 0.
Derive svTest as
You don't actually need the If..Then..Else. This Boolean logic will also work:
The trick is to set the stage variable to itself when you don't need to change it. For example, initialize svTest to 0.
Derive svTest as
Code: Select all
If <<error occurred>> And svTest = 0 Then 1 Else 0
Code: Select all
<<error occurred>> And svTest = 0
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
svErrorsFound = IF In.Group-ID=svLastGroup THEN IF In.Error=1 THEN svErrorsFound+1 ELSE SvErrorsFound ELSE IF In.Error=1 THEN 1 ELSE 0
svErrorState = IF SvErrorsFound=1 THEN 1 ELSE 0
svLastGroup = In.Group-ID
The first stage variable Counts the number of "Errors" up, resetting when the Group Change occurs. The second stage variable, "svErrorState" is your Output column Derivation and the last stage variable defines your last record Group-ID value.
svErrorState = IF SvErrorsFound=1 THEN 1 ELSE 0
svLastGroup = In.Group-ID
The first stage variable Counts the number of "Errors" up, resetting when the Group Change occurs. The second stage variable, "svErrorState" is your Output column Derivation and the last stage variable defines your last record Group-ID value.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>