Guys,
Im facing the following problem in the Transformer logic.
I have two input columns to my transformer 'Value' and 'Type'
I have one output 'flag' column which is to be populated as 'Y' or 'N' as per the logic below.
"For each 'Type' I should assign the value 'Y' to the output flag for that record for which 'Value' is maximum."
Example:
Type, Value, Flag,
A, 122, N
A, 136, Y
A, 126, N
B, 111, N
B, 156, Y
C, 187, Y
C, 163, N
C, 145, N
Can anyone give me the logic to be used in the transformer?
Thanks in advance,
Diya
Flag Logic
Moderators: chulett, rschirm, roy
Seems like impossible
I just gave u an example.There are 1000s of records in the input table with so many types.For each type i should pick up the row in which 'value' is maximum and then assign vale 'Y' to the flag...for all other rows i whould assign 'N'....
so if there are 'x' types I will have 'x' rows with flag='y' and the rest of the rows with flag='N'.
So writing a lengthy statement will not work...
Can u suggest any other idea...
Thanks
Diya
so if there are 'x' types I will have 'x' rows with flag='y' and the rest of the rows with flag='N'.
So writing a lengthy statement will not work...
Can u suggest any other idea...
Thanks
Diya
Looks like you need to run the data to a hashed file with all rows flagged as "N" and also to an Aggregator getting the max for the group and then output from the aggregator to a transformer where you set the flag accordingly, then write to the same hashed file. Then, move the data out of the hashed file.
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
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Sort by Type then in descending order by Value. Use stage variables to detect a change in Type and set the flag to 'Y' where this occurs and to 'N' otherwise.
Note that svIsChanged must occur (be evaluated) before svPrevType. Make sure that stage variables are initialized.
Code: Select all
svIsChanged @INROWNUM = 1 Or InLink.Type <> svPrevType
svPrevType InLink.Type
svFlag If svIsChanged Then "Y" Else "N"
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.