Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 170
  • Last Modified:

Using OR within an IF statement

Hello,

I'm trying to use an OR statement within an IF statement like below, but i know the syntax isnt correct can anyone help?

If('PUB."RE-TNCY-TRANS"."POSTING-WEEK"'=1 or 2,1,0)
0
TMC_UK
Asked:
TMC_UK
  • 7
  • 4
  • 3
  • +1
3 Solutions
 
elimesikaCommented:
Here it is
If(PUB."RE-TNCY-TRANS"."POSTING-WEEK" in (1,2,1,0))

Open in new window

0
 
elimesikaCommented:
Sorry , Misunderstood your problem

Is "POSTING-WEEK" a int ? Char ???
0
 
TMC_UKAuthor Commented:
Its an Int
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
elimesikaCommented:
So


this should be OK
If(PUB."RE-TNCY-TRANS"."POSTING-WEEK" in (0,1,2))

Open in new window

0
 
Kelvin SparksCommented:
Do you have an IIf expression here (not an If)
If so try:
IIf('PUB."RE-TNCY-TRANS"."POSTING-WEEK"'=1 or 'PUB."RE-TNCY-TRANS"."POSTING-WEEK"'=2,1,0)
 
Kelvin
0
 
TMC_UKAuthor Commented:
What about the true/false part for the 1 and 0?

Its an if else statement so i want to put where the posting week = 1 or 2 i need it to = 1 else equal 0. I then want to carry on this statement to say where posting week = 3, 4 5 or 6 then = 2 else equal 0.

Can you tell me how that would look?

0
 
awking00Commented:
case when posting week in (1,2) then 1
        when posting week in (3,4,5,6) then 2
        else 0
end
0
 
TMC_UKAuthor Commented:
Hi,

I've tried both the IIf solution and the solutions from elimesika but neither of these work, any other suggestions guys??!

Is it possible to do an OR in and IF then else statement, or am i asking the impossible?! I'm sure i've done it before but cant get the syntax quite right!
0
 
awking00Commented:
Is the case statement not available?
0
 
TMC_UKAuthor Commented:
Case statements arn't available in the software i'm using.

I'm using a package called hummingbird and Case statments are not supported in the calculation i'm trying to do. Can you do anIf statement with an OR contained within it or not?
0
 
awking00Commented:
I wouldl say yes, but you'll probably have to stack it like the following
iif(expr = 1,1, iif(expr = 2,1,iif(expr = 3,2,iif(expr = 4,2,iif(expr = 5,2,iif(expr = 6,2,0))))))
0
 
TMC_UKAuthor Commented:
I cant do IIf statements the function isnt supported, any other ideas?
0
 
awking00Commented:
What dbms are you using?
0
 
TMC_UKAuthor Commented:
Its a package called Humminbird and Openquery
0
 
TMC_UKAuthor Commented:
Answered partly
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 7
  • 4
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now