Avatar of hennanra3
hennanra3
Flag for United Kingdom of Great Britain and Northern Ireland asked on

Logical Operator should return Integer value in SSIS

Hi All,

I have a question as in SSIS I am using excel file source and in one of the columns I need to define attributes of that dimension. In order to do that I have to apply logical operator but it is returning the results in boolean i.e., either true false or '0' or '1'. However I want the numbers to be displayed after logical operator is applied. So, Sales column in showing data as :

Sales
28
74
165
34
321

And logical operator will work as
Sales>= 0 && Sales<=99 should be in "a. 0-99"
Sales>100&&Sales<199 should be in "b.100-199" and so on.

Currently I am using Derived Column but it is showing results in boolean form as mentioned above. But I want the numbers to be categorized for Sales. Please guide.

Thanks in advance.

P.S.  Currently Sales' column is of integer data type but can be changed
Microsoft SQL ServerSSIS* ETL

Avatar of undefined
Last Comment
hennanra3

8/22/2022 - Mon
Nakul Vachhrajani

The logical operators, by definition return boolean values. They evaluate to "true" or "false" and hence cannot return integers.

What you can do, however is to use the "Derived Column" components. In the derived column, you can define an expression which would return the required integer based on the specified conditions. You can use this expression to add a new column to your result set or replace an existing column.
HainKurt

try

(Sales / 100)*100 + "-" +  (Sales / 100)*100+99

Open in new window

hennanra3

ASKER
Nakul I tried to use an expression in Derived Column but in vain. Can you please guide?
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
hennanra3

ASKER
Thanks Huseyin , I tried but it's not working :/
hennanra3

ASKER
Hi Experts,

Still looking for your feedback.
Vitor Montalvão

Can't you use an IF clause? Something like:
IF (Sales BETWEEN 0 AND 99) 'a. 0-99'
IF (Sales BETWEEN 100 AND 199) 'b. 100-199'
IF (Sales BETWEEN 200 AND 299) 'c. 200-299'

Open in new window

⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
HainKurt

"I tried but it's not working :/"

what is happening?
ASKER CERTIFIED SOLUTION
HainKurt

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
hennanra3

ASKER
Thanks Huseyin it worked. Thanks :)