Page 1 of 1

populate output field depending on differnt value from input

Posted: Fri Oct 06, 2006 8:14 pm
by app2hxb
Hi all,

First let me thank you to help me. I really appreciate it. Now I need help in the following situation. My files look like this

INPUT OUTPUT
------- ---------
Field-a Out-a
Field-b-typ Out-x
Field-b-val Out-y
Field-c-typ Out-z
Field-c-val
Field-d-typ
Field-d-val

Now the derivation rules are as follows:

1) Out-a from Field-a
2) Out-x from Field-b-val if Field-b-typ = 'x' or from Field-c-val if Field-c-typ = 'x' or from Field-d-val if Field-d-typ = 'x'
3) Out-y from Field-b-val if Field-b-typ = 'y' or from Field-c-val if Field-c-typ = 'y' or from Field-d-val if Field-d-typ = 'y'
4) Out-z from Field-b-val if Field-b-typ = 'z' or from Field-c-val if Field-c-typ = 'z' or from Field-d-val if Field-d-typ = 'z'

So is anybody can tell to do this without using complicated logic in a "Transform" stage.

I really appreciate your help.

Thanks,

Hemanta

Posted: Fri Oct 06, 2006 11:25 pm
by kumar_s
Hi Hemanta,
Welcome to DSXchange!!! :D

I belive that, its metadata that you have given as INPUT and OUTPUT.

Code: Select all

1)Map Out-a to Field-a.
2) For Out-x
If Field-b-typ = 'x' Then Field-b-val Else If Field-c-typ = 'x' Then Field-c-val Else If Field-d-typ = 'x' Then Field-d-val
3) Out-y
If Field-b-typ = 'y' Then Field-b-val Else If Field-c-typ = 'y' Then Field-c-val Else If Field-d-typ = 'y' Then Field-d-val
4) Out-z
If Field-b-typ = 'z' Then Field-b-val Else If Field-c-typ = 'z' Then Field-c-val Else If Field-d-typ = 'z' Then Field-d-val


Hope you dont feel this as complicated.

Posted: Sat Oct 07, 2006 12:21 am
by ray.wurlod
Something like the derivations that kumar_s has given are as simple as you will ever get it; they map your requirements exactly. The actual derivations are syntactically incorrect, since there is no corresponding Else for the final Then (and there must be).

You DO have to do the condition testing (If..Then..Else) and select the input values accordingly. This is YOUR specification!

Out-a is derived as

Code: Select all

Inlink.Field-a

Out-x is derived as

Code: Select all

If Inlink.Field-b-typ = "x" Then Inlink.Field-b-val Else If Inlink.Field-c-typ = "x" Then Inlink.Field-c-val Else If Inlink.Field-d-typ = "x" Then Inlink.Field-d-val Else "???" 

You have not specified the value to be generated if none of Field-b-typ, Field-c-typ or Field-d-typ is "x". I have provided "???" as this value; change this as you see fit.

The other two output columns will have similar derivations.

If you find this too complex you can evaluate the individual results into stage variables, and apply the logic to those.