Solved

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

Posted on 2014-12-17
7
277 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 35

Assisted Solution

by:James0628
James0628 earned 200 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 300 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

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

691 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