hymal7
(Himal Gurung)
1
Hi,
I wanted to use a IF/THEN condition in a BAQ with an ‘OR’ function but I get error.
I have something like this for data type Y/N:
case
when PartBin.BinNum = ‘A’ OR ‘B’ OR ‘C’ then 1 or 0
end
Could someone please let me know how to use write the field code properly?
Many thanks
hymal7
Is this in a calculated field?
You could just use an “in” statement
Case
when PartBin.BinNum in (‘A’,‘B’,‘C’) then 1 else 0
end
3 Likes
Hogardy
(Pierre Hogue)
3
or use
case
when PartBin.BinNum = ‘A’ then 1
when PartBin.BinNum = ‘B’ then 1
when PartBin.BinNum = ‘B’ then 1
else 0
end
but Aaron version is nicer…
Pîerre
2 Likes
ckrusen
(Calvin Krusen)
4
The OR (or AND) compare the results of the conditions indepently of each other. You should have used
case when PartBin.BinNum == ‘A’ OR PartBin.BinNum ==‘B’ OR PartBin.BinNum ==‘C’ THEN 1 ELSE 0 end
The following is syntactically correct, but doesn’t do what you think.
case when PartBin.UserDecimal1 == 0 OR 1 THEN 1 ELSE 0 end
That would always return 1 as the second param of the OR is always true.
Edit: I instinctively made the comparisons double equal signs ‘==’… that would screw up the BAQ
1 Like