Go Premium for a chance to win a PS4. Enter to Win

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

Mutiple Conditions

I have these conditions in a view selection separated with an OR (|) however the view is only using one of the conditions. Is there another way of doing this?  Here is my code:

SELECT (@Contains(qcspecs; "Yes")) & (@Contains(koshstat; "Yes")) & (@Contains(microspecs; "Yes")) & (@Contains(takenoff; "No")) & (@Contains(scaleyesno; "No")) | (@Contains(qcspecs; "Yes")) & (@Contains(koshstat; "Yes")) & (@Contains(microspecs; "Yes")) & (@Contains(takenoff; "No")) & (@Contains(scaleyesno; "Yes")) & (@Contains(scalecomplete; "Yes"))

Willing to up the points for a good answer.
0
schmad01
Asked:
schmad01
1 Solution
 
David_GordonCommented:
Try this:

SELECT @Contains(qcspecs; "Yes") & @Contains(koshstat; "Yes") & @Contains(microspecs; "Yes") & 
@Contains(takenoff; "No") & (@Contains(scaleyesno; "No") | & (@Contains(scaleyesno; "Yes")
& @Contains(scalecomplete; "Yes")))



Use parentheses to group conditions as per the intended logic in this part of the code: (@Contains(scaleyesno; "No") | & (@Contains(scaleyesno; "Yes")
& @Contains(scalecomplete; "Yes"))); This translates to "if scaleyesno is No OR (if scaleyesno is Yes AND scalecomplete is yes)"

Try to avoid using extra parentheses if possible. Although they are technically correct, they are an obstacle to comprehension.

0
 
HemanthaKumarCommented:
SELECT @Contains(qcspecs; "Yes") & 
@Contains(koshstat; "Yes") & 
@Contains(microspecs; "Yes") & 
@Contains(takenoff; "No") & 
(@Contains(scaleyesno; "No") | @Contains(qcspecs; "Yes")) & 
@Contains(koshstat; "Yes") & @Contains(microspecs; "Yes")&
@Contains(takenoff; "No") & @Contains(scaleyesno; "Yes")&
@Contains(scalecomplete; "Yes")

Probably you should group the or clause.

If you could put the logic in plain words then I can see where it goes wrong.

PS: I have removed the extra brackets which is not necessary.

~Hemanth
0
 
zvonkoCommented:
My proposal is:
SELECT (@Contains(qcspecs; "Yes")&@Contains(koshstat; "Yes")&@Contains(microspecs; "Yes")&@Contains(takenoff; "No"))&(@Contains(scaleyesno;"No")|(@Contains(scaleyesno; "Yes")
&@Contains(scalecomplete;"Yes")))

<|;-)

0
 
zvonkoCommented:
Explanation:
Always required:
qcspecs="Yes",koshstat="Yes",microspecs="Yes",takenoff="No"

but scalecomplete is not set: scaleyesno="No"
Or: scaleyesno="Yes" AND scalecomplete="Yes"

Dacor?

0
 
schmad01Author Commented:
It worked after I took out the extra & next to the |. I think you overlooked that by accident.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now