Crystal reports suppression formula with multiple OR operators not working

68,729

Solution 1

Its a bit confusing but try below way...

if you are trying to meet all 3 conditions then you need to write that first because if any of the one condition is met first then control will never reach to statisying all 3 conditions and after that your regular conditions to satisy each one.

so your formula would be:

If
({table1.field1} = "V1" and
{table1.field2} <> "V2" and
PageNumber > 1)
then false        //don't Supress when all are met
else if {table1.field1} = "V1"
Then false        //field1 is met so don't supress
else if {table1.field2} <> "V2"
then false        //field2 is met don't supress
else if PageNumber > 1
then false       //3rd condition is met don't supress
else true        //Supress anything as all conditions were failed

Solution 2

Suppression formulas work by suppressing the object when it evaluates to true and not the other way around. In other words, you need to negate your entire formula.

not(
    {table1.field1} = "V1" or
    {table1.field2} <> "V2" or
    PageNumber > 1
   )

becomes, via De Morgan's Law

not({table1.field1} = "V1") and
not({table1.field2} <> "V2") and
not(PageNumber > 1)

which can then be simplified to:

{table1.field1}<>"V1" and
{table1.field2="V2" and
PageNumber = 1
Share:
68,729
pwlm
Author by

pwlm

Updated on March 06, 2020

Comments

  • pwlm
    pwlm about 4 years

    I am trying to add a very simple suppression formula to my Crystal Report (XI) field but it is not working as expected.

    I would like a text box to be visible if certain conditions are met, otherwise suppress. With the suppress box ticked my current formula is below:

    {table1.field1} = "V1" or
    {table1.field2} <> "V2" or
    PageNumber > 1
    

    If any combination of 1, 2 or all 3 of the conditions are met then display the text (neither field1 nor field2 ever return null).

    However Crystal Reports is only evaluating the first line of the formula; if field1 = V2 then the field does not show.

    Any assistance would be most appreciated.