If and Then Else Statement

If and Then Else Statement

I am a self taught beginner. I am looking to get additional {billing.items} that will only show when standard {billing.items} are present. Then if not present, just get the standard. I am using an IF AND THEN ELSE statement. Nothing is being returned from the beginning IF AND THEN, I am only getting the ELSE.

when i make a simple IF THEN statement with the entire list, i and getting all data. So the data does exist. But i need the additional items to be dependent on if the standard items are present. I am stumped.

( if ({billing.items} in [1244, 1245, 1246, 1247, 1248, 1249, 1250] and {billing.items} in [1296, 2390, 2391, 2392, 2393]) then true else {billing.items} in [1244, 1245, 1246, 1247, 1248, 1249, 1250] )

1 Answer

If I understand correctly, you want to check if at least one item of each list is available.

Crystal Reports always looks at the formula on a record basis. So {billing.items} is always evaluated as the value of the current record and thus the statment will always be false as {billing.items} only contains one value.

To solve this, you can create three separate formulas one with the first list and one with the second list. In the third formula (or suppression formula) you can check if the "Maximum" of each list-formula on the report is true.

Formula "@List1"

{billing.items} in [1244, 1245, 1246, 1247, 1248, 1249, 1250]

Formula "@List2"

{billing.items} in [1296, 2390, 2391, 2392, 2393]

Check

if Maximum({@List1})=true and Maximum({@List2})=true then
    // Standard-Items are present
else
    // Standard-Items are NOT present
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

David Miller
Author

David Miller

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.