How to implement this logic DS PX
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 32
- Joined: Tue Mar 09, 2010 5:56 am
- Location: Bangalore
How to implement this logic DS PX
If for a account number there are multiple values are present in another field, how can I take each value and propagate it to different fields.For e.g. if there are multiple dates for a single account no coming from a single source field,and in the target there are different target columns are present where we need to propagate the respective values.The first date should go to the first column, the second should go to the second column and thus so on.How to implement this in datastage PX.For a single account no the date field which is having multiple values is not coming in a single row with a seperator, they are coming in different rows in a distinct field.
Thanks & Regards,
Partha
Partha
-
- Premium Member
- Posts: 32
- Joined: Tue Mar 09, 2010 5:56 am
- Location: Bangalore
yes, Acct1,Date1 Acct1,Date2 ... Acct1,Daten in multilpe rows for the same account no i.e. there are multiple date vales for a single account no , and we need to take sort the date and then min date need to go to dat1, next one to dat2 and so on in different target columns for the same account no.
Thanks & Regards,
Partha
Partha
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
How do you think that will work ?
Firstly, having multiple dates will make your target structure dynamic. i.e. the first account may have 2 dates whereas the second may have 10.
So you must have some fixed number of date columns.
Search for "Vertical Pivot" and use stage variables to arrange the dates.
Alternatively you can use the database query to provide the dates in order in a subquery and select rownum in the main. This will assist you to order using the rownum column.
Firstly, having multiple dates will make your target structure dynamic. i.e. the first account may have 2 dates whereas the second may have 10.
So you must have some fixed number of date columns.
Search for "Vertical Pivot" and use stage variables to arrange the dates.
Alternatively you can use the database query to provide the dates in order in a subquery and select rownum in the main. This will assist you to order using the rownum column.
-
- Premium Member
- Posts: 32
- Joined: Tue Mar 09, 2010 5:56 am
- Location: Bangalore
Try the following:
If the number of output date columns is fixed then you could have that many output links from a transformer stage and extract and pass the date values into the output.
So , if you have 10 output date field in the Table, create 10 output links from a transformer and pass one date field into each of the 10 outputs.
To extract the individual date fields you could use the Field function is the transformer.
Then , funnel all these links into a single output link. Now you will end up with one record for every Acct - Date combination. This entire activity can also be done in an external script Or a BuildOp.
Next step would be to sort the data on the Acct - Date combination so that for each account , your dates are in the ascending or desending order.
Next , you will have to do a kind of a Reverse Pivot , where where you plug in each date into the corresponding output Date column. To do this you will have to use a combination of a transformer stage and also a remove duplicate stage.
If the number of output date columns is fixed then you could have that many output links from a transformer stage and extract and pass the date values into the output.
So , if you have 10 output date field in the Table, create 10 output links from a transformer and pass one date field into each of the 10 outputs.
To extract the individual date fields you could use the Field function is the transformer.
Then , funnel all these links into a single output link. Now you will end up with one record for every Acct - Date combination. This entire activity can also be done in an external script Or a BuildOp.
Next step would be to sort the data on the Acct - Date combination so that for each account , your dates are in the ascending or desending order.
Next , you will have to do a kind of a Reverse Pivot , where where you plug in each date into the corresponding output Date column. To do this you will have to use a combination of a transformer stage and also a remove duplicate stage.