Page 1 of 1

if then else

Posted: Mon Sep 03, 2007 3:21 am
by scorpion
Hi,

I am looking for simple IF-THEN-ELSE Logic for my below reqrment...

Could any one help me on this please..

if column1 = 'DSX' Then 'Datastage' Else 'Dstage' Else 'Ascential'

how do i keep im if then else in transformer?

Thanks all!

Posted: Mon Sep 03, 2007 3:46 am
by scorpion
HiAll ,

In my requirement i need to use 2 else statements..

if the value of the ColumnA = 'dsx' then populate TARCOL1,if this is blank THEN populate TARCOL2.if this column also blank then populate TARCOL3.

any Advises please?

Re: if then else

Posted: Mon Sep 03, 2007 3:49 am
by Abu@0403
Your requirement is unclear.

Anyhow I will give you a sample logic. Check if this is fine.

If Col1 = "DSX" Then "DataStage"
Else If Col1 = "DX" Then "Dstage"
Else "Ascential"

If you want exact solution then give the condition to get "Dstage" in your requirement.

Posted: Mon Sep 03, 2007 3:51 am
by scorpion
Hi Abu,

Thanks for the reply,below is my exact reqrmnt:

if the value of the ColumnA = 'dsx' then populate TARCOL1,if this is blank THEN populate TARCOL2.if this column also blank then populate TARCOL3.

Could you please advise on this?

Sorry for the confusion..

Posted: Mon Sep 03, 2007 4:00 am
by Abu@0403
If ColumnA = 'dsx' Then
If Len(Trim(TARCOL1))=0 Then
If Len(Trim(TARCOL2))=0 Then TARCOL3
Else TARCOL2
Else TARCOL1
Else
<Condition if ColumnA<>"DSX">

I havent used this function like len(Trim) rather I have routine being used. So check if this is correct.

Posted: Mon Sep 03, 2007 4:29 am
by scorpion
Hi ,

values are in my columns are varchar type.So some are the values are nulls.

rqrmnt:

if the value of the ColumnA = 'dsx' then populate TARCOL1,if this value is null THEN populate TARCOL2.if this column values is also null then populate TARCOL3.

Posted: Mon Sep 03, 2007 5:26 am
by scorpion
can any one helpme on this please?

Posted: Mon Sep 03, 2007 7:28 am
by chulett
:? Still unclear. If you spell out what needs to happen in writing under all conditions, it should be pretty easy to do whatever it is you need to do.


If ColumnA = 'dsx' then populate TARCOL1 with what?

If ColumnA is null, then populate TARCOL2 & TARCOL3 with what?

Posted: Mon Sep 03, 2007 7:31 am
by scorpion
Hi Chullet,

ColumnA,TARCOL1,TARCOL2 & TARCOL3 are my source columns:

And i have to populate one my target column(TARGETCOL) like below:

if the value of the ColumnA = 'dsx' then map TARCOL1,Else map TARCOL2.if this column values is also null then populate TARCOL3.

Posted: Mon Sep 03, 2007 7:39 am
by chulett
Let's try again. This makes no sense as you've said it is a source column:

"if this column values is also null then populate TARCOL3."

Stop saying the same thing over and over and rephrase it so it makes more sense. Which column is 'this column'? All I can gather right now is if ColumnA = 'dsx' then you need to populate TARGETCOL with TARCOL1 else populate TARGETCOL with TARCOL2. So far, that's just one simple perfectly normal if-then-else statement.

Other than that... :?

Posted: Mon Sep 03, 2007 7:47 am
by scorpion
Thanks for your reply chullet,

Othere than that

if TARCOL2(second source column) also null then populate TARGETCOL with TARCOL3(3rd source column)..

so to populate TARGETCOL:

if the value of the ColumnA = 'dsx' then map TARCOL1,
Else map TARCOL2.if this column value(TARCOL2) is null then mapTARCOL3.

here i need 2 ELSE conditions.

Posted: Mon Sep 03, 2007 9:06 am
by chulett
Ok, that makes more sense. You need two if-then-else expressions, not just "two else conditions". Psuedo-code for the TARGETCOL derivation:

Code: Select all

If ColumnA = 'dsx' Then TARCOL1 Else If IsNull(TARCOL2) Then TARCOL3 Else TARCOL2
You'll need to add link names and make it all PX-like (not sure about IsNull in PX) but you should get the idea now.