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!

Only report if there is a 30% increase or decrease from previous group

Status
Not open for further replies.

DamoOz

Programmer
Oct 18, 2000
24
AU
Hi

I have just created a program to collect error information from a switch and populate a database. I have a report to display the error information for the last 3 hours, totals treatment etc.

I now require a report that only reports on errors that have a 30% increase or decrease from the previous hour which will then be email to the appropiate staff.

I'm sure this is quite straightforward but I have been scratching my head for days.

Cheers
 
well I assume that you are grouped on the basis of an hour

you don't say how you propose to display your results or the fields involved but here is the basic approach

your detail section may have the following format

{@previousValue} {Table.Value} {@PercentDiff}

the section expert would have the following formula for conditional suppress:

WhilePrintingRecords;
if previousIsNull({Table.Value}) then
true
else if abs(({Table.Value} - previous({Table.Value}))/
{Table.Value}) < .3 then
true
else
false;


I am a bit nervous about this since you have a potential division-by-zero error if {Table.Value} can able to be
equal zero...it is easy to trap but I don't know how you want to handle this case.

@PreviousValue

WhilePrintingRecords;

previous({Table.Value});

@PercentDiff

WhilePrintingRecords;
abs(({Table.Value} - previous({Table.Value}))/
{Table.Value});

again no provision here for division by zero... Jim Broadbent
 
Jim

I have tried something like this but my problem is that I do not have a {table.value}. I am just keeping a count of the number of errors and I want to report if the number of errors increase or decrease by 30%. The previous function does not allow me to do a previous(count({table.error}).

My main report is straightforward. I have grouped by Hour and only display the last 3 hours. I have other grouping like route destination and error treatment and I only want to report where the count of errors to a destination increases or decreases by 30%.

I could do the in VB code but it would be a bit drawn out and program execution time could be quite long. I'm sure there is a way I can do this in CR and then use the CR report to send out page alarms to the on-call techs.

Thanks
Damien
 
This might work for you, providing you're just using the summary data at the group footer level:

Create 3 formulas;

one to reset a counter variable (group header)
whileprintingrecords;
numbervar MyCount :=0;

one to count (detail)
whileprintingrecords;
numbervar MyCount;
MyCount := MyCount + 1;
MyCount

one to compare the previous count and set a suppressme variable (group footer)

whileprintingrecords;
global numbervar PrevCount;
global numbervar MyCount;
global booleanvar suppressme;

if MyCount < PrevCount // adjust this to do percent instead
then
suppressme := true
else
suppressme := false;
prevcount := MyCount;
prevcount

Now create a second group footer section, and place the fields to display in it, now add the suppressme variable into the suppress formula.
whileprintingrecords;
booleanvar suppressme;
suppressme

You can probably substitute a CR count for the variable counter.

If you need to show the data at the detail level, then I guess that you're locked into using a subreport in a similar fashion.

There's probably a better way.

-k kai@informeddatadecisions.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top