manoj yadla
manoj yadla

Reputation: 17

SSIS derived column for the case condition doesn't show the exact results as needed

I am this case conditional expression as a derived column, the result i not as expected

(DT_STR,255,1252)((Step1_Emc_stg_Heading >= "315" && Step1_Emc_stg_Heading <= "45") ? "Northbound"
: (Step1_Emc_stg_Heading >= "46" && Step1_Emc_stg_Heading <= "135") ? "Eastbound"
: (Step1_Emc_stg_Heading >= "136" && Step1_Emc_stg_Heading <= "225") ? "Southbound" 
: (Step1_Emc_stg_Heading >= "226" && Step1_Emc_stg_Heading <= "314") ? "Westbound" : "Nobound")

Upvotes: 1

Views: 56

Answers (1)

Hadi
Hadi

Reputation: 37368

I think that the problem is in the first case

Step1_Emc_stg_Heading >= "315" && Step1_Emc_stg_Heading <= "45"

you have to replace 45 with a number bigger than 315 or you have to use logical OR || instead or logical And &&

Step1_Emc_stg_Heading >= "315" || Step1_Emc_stg_Heading <= "45"

Update 1

Try the following expression (use numbers instead of string, and reorder conditions):

(DT_STR,255,1252)((DT_I4)Step1_Emc_stg_Heading <= 45 ? "Northbound"
:  (DT_I4)Step1_Emc_stg_Heading <= 135 ? "Eastbound"
:  (DT_I4)Step1_Emc_stg_Heading <= 225 ? "Southbound" 
:  (DT_I4)Step1_Emc_stg_Heading <= 314 ? "Westbound" 
:  (DT_I4)Step1_Emc_stg_Heading >= 315 ? "Northbound" : "Nobound")

Upvotes: 1

Related Questions