Page 1 of 1

can we use if..then...else conditions in a stage variable

Posted: Tue May 15, 2007 9:18 am
by bgs_vb
Hi,

can anybody tell me whether we can use if..then...else / CASE conditions in a stage variable..

thanks in advance.

bgs_vb

Posted: Tue May 15, 2007 9:20 am
by DSguru2B
If then else ----->Yes
Case ---- > No.

Posted: Tue May 15, 2007 9:27 am
by bgs_vb
i have a case

source_fld should be compared for numeric or text

if numeric then < populate into target_fld _1> and < put 'n' to target_fld_txt>

otherwise <populate into target_fld_2> and <put 't' to target_fld_txt>

how do i solve it.

Thanks,
bgs_vb

Posted: Tue May 15, 2007 9:39 am
by DSguru2B
Use a simple if then else statement in stage variable to see if its numeric or not.
Use another if then else statement in the derivation to check on the value of stage variable and putting proper values for particular columns.

Posted: Tue May 15, 2007 9:43 am
by us1aslam1us
How about just defining the Column derivations something like...

Code: Select all

target_fld _1    >>  If num(in.col) then in.col else ''
target_fld _2    >>  If num(in.col) then '' else in.col 
target_fld _txt  >>  If num(in.col) then 'n' else 't'

Posted: Tue May 15, 2007 9:45 am
by bgs_vb
i tried with Num(field) and stored it in stagevar

when i try to check like:

if (stagevar = 1) then
source_fld
else
'Txt'
end

it shows error

bgs_vb

Posted: Tue May 15, 2007 10:13 am
by chulett
No 'end' required.

Posted: Tue May 15, 2007 10:32 am
by bgs_vb
StageVariable Derivation - Num(DSLink4.Src)

Target Derivation - < If (StageVar = 1) Then DSLink4.Src > i am getting error here.

Posted: Tue May 15, 2007 10:36 am
by us1aslam1us
If condition then 'Result1' else 'Result2'. This is the syntax. What is the error message?

Posted: Tue May 15, 2007 10:37 am
by chulett
Do we have to guess what the error is? Where's your 'else'?

Posted: Tue May 15, 2007 11:03 am
by bgs_vb
StageVariable Derivation - Num(DSLink4.Src)

Target Derivation - < If (StageVar = 1) Then DSLink4.Src Else 'T' End>

even if i put like this it shows 'General Syntax Error'

Posted: Tue May 15, 2007 11:20 am
by chulett
As I said, there's no end required in a derivation if-then-else.

Posted: Tue May 15, 2007 12:00 pm
by bgs_vb
Yes it works...

Thanks all...

Posted: Tue May 15, 2007 5:01 pm
by ray.wurlod
Time to mark the thread as resolved, then?