[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
• Status: Solved
• Priority: Medium
• Security: Public
• Views: 714

# Set Flag in Crystal Reports

I have a report that has 2 tables

I want to be able to look at all of the items sold on an invoice and if one of the items equals Category 1 I want a Flag that is set to True for all of the items in the Invoice.  If no items exist in Category 1 then the Flag shoudl be False for all Items.

How do I do this?
0
• 2
• 2
1 Solution

Commented:
Try this idea

Create a formula
Name - Category1
If {CategoryField} = 1 then
1
Else
0

Use a formula like this for the flag
Sum({Category1}) > 0

mlmcc
0

Professor of MIS at Penn State Erie and Owner, Millet SoftwareCommented:
mlmcc has the right approach.
Assuming the report is grouped by {Invoice_N} you would need to tweak the last formula.
Sum({Category1}) > 0
use
Sum({Category1}, {Invoice_N}) > 0
0

Author Commented:
Thanks for your help.  IdoMillet - the second formula works.  I named this formula "Flag"

I want to create another formula that looks at "Flag"

If "Flag" = True then SoldItem.Cost / 2   (I want the cost for them items sold divided by 2)

when I create my new formula that looks at "Flag" I get an error:  A summary has been specified on a non-recurring field.

Any suggestions?

Thanks,
Mathew
0

Commented:
Formulas can be selected from the field list

If {@Flag} = True then {SoldItem.Cost} / 2

If the Flag formula uses a summary function then you can't summarize it.

DO you want the entire invoice to be half or just selected items?
For all items try

If {@Flag} = True then
Sum({SoldItem.Cost}, {Invoice_N})  / 2
Else
Sum({SoldItem.Cost}, {Invoice_N})

mlmcc

0

Author Commented:
that was it.  I needed to use the formula in the summary and it's what I wanted.

thanks so much
0

## Featured Post

• 2
• 2
Tackle projects and never again get stuck behind a technical roadblock.