Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2014-12-17
7
Medium Priority
?
289 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
Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

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

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

609 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