Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make a sum 2

Status
Not open for further replies.

davidchardonnet

Programmer
Mar 21, 2001
167
FR
[CR XI]

Hello,

I have a table with 3 fields in my database:

table(id,amount,theboolean)

I made a report displaying the "amount" field for each row in the table.
But I need to display "amount" only if "theboolean" is true
and when "theboolean" is false, i want to display the "sum(amount) where theboolean=false" at the end of the report.

I can't figure out how to do this in Crystal Reports. Can somebody help me?

Thank you

David
 
Two step process. First eliminate the false records from your report with a record selection formula. Go to report, selection formulas, record and enter a simple formula:

{theBoolean}

Get this formula by double clicking on the field name. Normally a record selection formula must evalaute to true or false (ex: {CustName} Startswith "A") butin your case your field is a boolean, so you just need to place the field itself in the record selection formula.

To get your sum, goto the report canvas and right click the field you want summed, and select insert, grand total.


Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports
 
The first step is Ok now. Thank you for this dgill

But I still have a problem for the second part because I have to sum the data that is not displayed in the report.

I display the lines where {theboolean} is true
I want to sum the lines where {theboolean} is false

 
Remove the record selection formula, and instead put it in the Group selection area (report->selection formula->GROUP). Now you will have only the records with True displayed, but the other records are available in the report. Create a formula and place it in the detail section:

if {table.theboolean} = false then {table.amount}

Right click on this and insert a grand total (sum). You can do the same for the true records, if you wish.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top