Hi ,
Please help me how to implement this logic in DS.
soure is coming like this
code1 val1 group1
____________________________________
1 p abc
0 p abc
1 a fpg
0 a fpg
------------------------------------------------
out put should be like this
code1_val1 group1
------------------------------
1p0p abc
1a0a fpg
Thanks in advance,
Chris
Logic needed
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 194
- Joined: Thu May 11, 2006 9:42 am
Logic needed
Thanks,
Chris Jones
Chris Jones
Re: Logic needed
code1 val1 group1
____________________________________
1 p abc
0 p abc
1 a fpg
0 a fpg
------------------------------------------------
Before getting to design.. i wanted to know .. How many times can a Group appear in a file. i.e., say do u have any requirement that "abc" appears only twice or at a max. for N times.
regards.
Kiran.
____________________________________
1 p abc
0 p abc
1 a fpg
0 a fpg
------------------------------------------------
Before getting to design.. i wanted to know .. How many times can a Group appear in a file. i.e., say do u have any requirement that "abc" appears only twice or at a max. for N times.
regards.
Kiran.
g.kiran
Welcome aboard
Sort your incoming data by val1.
Use two stage variables to do the group changing dance, say cond and prevVal. They should be in the same order as i specified. cond first and prevVal second.
after doing that your output data will look like
pass the output through an aggregator, group on the code1_val1 and group1 and specify the "Last" option for middle column
that will give you your desired output.
Regards,
Sort your incoming data by val1.
Use two stage variables to do the group changing dance, say cond and prevVal. They should be in the same order as i specified. cond first and prevVal second.
Code: Select all
cond- if @INROWNUM =1 OR INLINK.val1 = prevVal then cond:INLINK.code1:INLINK.val1 else INLINK.code1:INLINK.val1
prevVal- INLINK.val1
Code: Select all
p 1p abc
p 1p0p abc
a 1a fpg
a 1a0a fpg
that will give you your desired output.
Code: Select all
p 1p0p abc
a 1a0a fpg
Last edited by DSguru2B on Fri Jun 23, 2006 7:23 am, edited 2 times in total.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
-
- Participant
- Posts: 194
- Joined: Thu May 11, 2006 9:42 am
Re: Logic needed
Hi,
In my requirement "abc" appears only twice .
In my requirement "abc" appears only twice .
DSkkk wrote:code1 val1 group1
____________________________________
1 p abc
0 p abc
1 a fpg
0 a fpg
------------------------------------------------
Before getting to design.. i wanted to know .. How many times can a Group appear in a file. i.e., say do u have any requirement that "abc" appears only twice or at a max. for N times.
regards.
Kiran.
Thanks,
Chris Jones
Chris Jones
[quote="DSguru2B"]Try to go through my logic. In that, it doesnt matter how many times abc or for that matter any other value exist. All you need is to be sorted by val1 and the design will take care of the rest.[/quote
That will definitely work, but if you know for sure that it appears twice, I would always go for a self join query. I always prefer finishing such stuff at the database end itself.
That will definitely work, but if you know for sure that it appears twice, I would always go for a self join query. I always prefer finishing such stuff at the database end itself.
It took me fifteen years to discover I had no talent for ETL, but I couldn't give it up because by that time I was too famous.
Re: Logic needed
HI
use this select statement u can get as u required
select max(code1) || max(var1) ||min(code1)||min(var1),group1 from abc group by group1
Thanks
Dharma
use this select statement u can get as u required
select max(code1) || max(var1) ||min(code1)||min(var1),group1 from abc group by group1
Thanks
Dharma
chrisjones wrote:Hi ,
Please help me how to implement this logic in DS.
soure is coming like this
code1 val1 group1
____________________________________
1 p abc
0 p abc
1 a fpg
0 a fpg
------------------------------------------------
out put should be like this
code1_val1 group1
------------------------------
1p0p abc
1a0a fpg
Thanks in advance,
Chris