Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create derived column using multiple conditional operators

Status
Not open for further replies.
Jun 19, 2008
19
US
I'm trying to create a derived column using the conditional operator.

I have a source column called f_print_task that contains the following values 0,1,2,3.

Based on the value in the f_print_task column I need to populate two destination columns with values.


if f_print_task = 0 I want to put values 0 in the destination column NonPM and OnPM

if f_print_task = 1 I want to put values 0 in the destination column NonPM and value 1 in the OnPM column

if f_print_task = 2 I want to put values 1 in the destination column NonPM and value 1 in the OnPM column

if f_print_task = 3 I want to put values 1 in the destination column NonPM and value 0 in the OnPM column


Currently I have for my expression in the derived column transformation editor FO_PRINT_TASK >=0 ? 0 : 0 which works....but I need to add the other three expressions for this same column...... something like
FO_PRINT_TASK >=0? 0:0 ? 0:1 ? 1:1 ? 1:0 but this errors out.

Can this be done using a conditional expression?
 
you need to use the logical or operator and break each check into a test which are then linked by the logical or similiar to the following code snippet which is untested. but should get you on the right track you need to do the test for each column you want to output from the derived column task.
Code:
f_print_task == 0 ? NULL : 0 || f_print_task == 1 ? NULL : 1 || etc

Paul
---------------------------------------
Shoot Me! Shoot Me NOW!!!
- Daffy Duck
 
Thanks for the response....But there still seems to be an issue with either the format or the operator

I used the following format...

FO_PRINT_TASK == 0 ? 0 : 0

and it works fine...but with I try to add the other condition
FO_PRINT_TASK == 0 ? 0 : 0 || FO_PRINT_TASK == 1 ? 0 : 1

it does not work.

?????????????
 
It Appears you need to set you false value to be your next conditional check. This snipet was actually build in the Dericed Column task so it was checked for syntax by the transform.

Code:
([DCDAY] == 1 ? ([DCDAY]==2? 0 : 2): 1)
so to test 3 conditions
Code:
([DCDAY] == 1 ? ([DCDAY]==2? ([DCDAY]==2? 0 : 3) : 2): 1)

Paul
---------------------------------------
Shoot Me! Shoot Me NOW!!!
- Daffy Duck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top