Solved

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

Posted on 2014-12-17
7
256 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
  • 3
  • 2
  • 2
7 Comments
 
LVL 100

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 100

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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 34

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 100

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 34

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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

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 …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now