?
Solved

Crystal Reports showing only 500 records and getting the average gross profit

Posted on 2014-12-17
7
Medium Priority
?
283 Views
Last Modified: 2014-12-18
I have  over 2,000 items but would like to only show 500 on the report and do an average gross profit.
The problem that I am having is that I am displaying only 500 records by using this code in the detail section: RecordNumber <= Count({INVENTOR.ITEM_ID}) - 500

When I do the summary it shows me the summary for all 2,000 items on report not the 500 items being printed.
I need help to show the gross profit on the 500 items on the report.

Thanks.
0
Comment
Question by:CarloVasquez
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 40505428
DO you have 1 record per item?

Do you care which 500 show?

As you have found out summaries use all the records in the report not just the visible records.
You need to
1.  Create a selection filter that limits you to 500 items, consider using a TOP N query
2.  Create formulas that do the calculations rather than using the summary functions

Formula method
In the report header add a formula
WhilePrintingRecords;
Global NumberVar GrossProfit;
''

Open in new window


in the detail section or the section where you show the item information add a formula
WhilePrintingRecords;
Global NumberVar GrossProfit;
If RecordNumber <= Count({INVENTOR.ITEM_ID}) - 500 then
     GrossProfit := GrossProfit + {GrossProfit Field};
''

Open in new window


In the report footer add a formula to display the profit
WhilePrintingRecords;
Global NumberVar GrossProfit;
GrossProfit

Open in new window


If I read your supression correctly that is actually showing the first Count - 500 items or in your case with 200  it will show 1500

mlmcc
0
 

Author Comment

by:CarloVasquez
ID: 40505547
I am getting an error "A Boolean is required here" on the first code:

WhilePrintingRecords;
Global NumberVar GrossProfit;
''

I am putting this on the Report Header, Suppress, and click on x2 to enter code.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 40505713
No that should be a regular formula that is created then put on the report as a field in the report.

mlmcc
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 35

Assisted Solution

by:James0628
James0628 earned 800 total points
ID: 40506721
mlmcc already asked this, but do you care which 500 records are used?

 Your suppression formula is suppressing anything before the last 500 records.  For example, if there were 600 records, it would suppress the first 100.  The test in mlmcc's second formula will need to be changed, but the specific test will depend on which records you want to include (first 500, or last 500).

 If you want to include the last 500, change <= to >.  Since the original test was deciding which records to suppress, and mlmcc's test is deciding which records to include, you need to reverse the test (change <= to >).

 Of course if you want to include the first 500 instead, you can just use RecordNumber <= 500.


 You also mentioned an average, and you'd need a count for that.  Assuming that the report could include fewer than 500 records, you'd need to check for that and use 500 or the actual record count, whichever was lower.  You could use Minimum ( [ Count ({INVENTOR.ITEM_ID}), 500 ]) to get that count.

 James
0
 

Author Comment

by:CarloVasquez
ID: 40506996
I did not get this statement:

'If I read your suppression correctly that is actually showing the first Count - 500 items or in your case with 200  it will show 1500'

Indeed I just want to add the first 500 records from highest to lowest. This I believe the sort will take care of, while delivering the report.  I just don't know where you get the 200 and show 1,500 in the above statement.  :/

Where would the Minimum ( [ Count ({INVENTOR.ITEM_ID}), 500 ]) formula go. To to the average what I am doing is hard coding the result that I have from mlmcc and divide that by 500. This would give me the average.
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 1200 total points
ID: 40507146
James is correct.  I forgot that was a suppression formula not a visible formula so my logic was backwards.

You only need James Minimum formula if you might have fewer than 500 records..  You use it as the divisor in the average calculation.  If you know you will always have at least 500 records to pick from, hardcoding the 500 will work.

The 200 in my statement should have been 2000.

James is correct that the test in my formula needs to be changes.  The calculation formula should be
WhilePrintingRecords;
Global NumberVar GrossProfit;
If RecordNumber > Count({INVENTOR.ITEM_ID}) - 500 then
     GrossProfit := GrossProfit + {GrossProfit Field};
''

Open in new window


mlmcc
0
 
LVL 35

Expert Comment

by:James0628
ID: 40507779
I think mlmcc has covered everything, but just ask if you still have any questions.

 James
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question