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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to calculate 1

Status
Not open for further replies.

oradba101

MIS
Feb 28, 2003
318
US
Greetings,

I am using Crystal XI.

The issue is rather complex and if I do not provide enough details please let me know.

The first calcualtion is the minimum and the maximum values of a numeric field with three decimal places. The field is called ppbv.

The secong is a parameter based upon user selection Let's say it is 4. This number is used to compute the ranges between the minimum and maximum values of ppv. The formulas for this are called x1, x2, x3 and X4. So if the maximum value for ppbv is 1 then

x1 = 0 - .25
x2 = .26 - .50
x3 = .51 - .75
x4 = .76 - 1

Now, I need to count the number of records that fall into the range of each formula and have not been able to do so. Can anyone assist?

Regards,


William Chadbourne
Programmer/Analyst
 
Please show the content of the formulas you are currently using for x1,x2,x3, and x4.

-LB
 
Hi, LB

Formula "divisor"

(Maximum ({@ppbv}, {RESULT.ANALYTE}) - Minimum ({@ppbv}, {RESULT.ANALYTE})) / {?bins}

Formula "x1"

If {?bins} >= 3 Then
0 + {@divisor}

Formula "x2"

If {?bins} >= 3 Then
{@x1} + {@divisor}

Formula "x3"

If {?bins} >= 3 Then
{@x2} + {@divisor}

Formula "x4"

If {?bins} >= 4 Then
{@x3} + {@divisor}

Regards,



William Chadbourne
Programmer/Analyst
 
Okay, I would use a variable like this:

whileprintingrecords;
numbervar x1;
numbervar x2;
numbervar x3;
numbervar x4;
if {@ppbv} <= {@x1} then
x1 := x1 + 1 else
if {@ppbv} <= {@x2} then
x2 := x2 = 1 else
if {@ppbv} <= {@x3} then
x3 := x3 + 1 else
if {@ppbv} <= {@x4} then
x4 := x4 = 1;


Note that it is better NOT to use ranges, as you could miss values that fall between .25 and .26, e.g., .254, unless you explicitly round to digits.

Then use separate formulas in the report footer that display the results;

whileprintingrecords;
numbervar x1; //or x2,x3,etc.

If you want the values at the group level you will have to add a reset formula in the group header that sets each variable to zero, and then move the display formulas to the group footer.

-LB
 
Hi, LB

How does one put a reset formula in a group header? Could ypu please provide an example?

Thanks,


William Chadbourne
Programmer/Analyst
 
whileprintingrecords;
numbervar x1;
numbervar x2;
numbervar x3;
numbervar x4;

if not inrepeatedgroupheader then(
x1 := 0;
x2 := 0;
x3 := 0;
x4 := 0
);

-LB
 
Thanks, LB

Worked like a charm.

Now for the hard part (at least for me)

I have to take the results and put them into a histogram

The x variables are for the x-axis
The counts are for the y-axis

How would I do this?

Thanks,


William Chadbourne
Programmer/Analyst
 
I'm not sure. You should have laid all of your requirements out in your first post. Sorry.

-LB
 
Hi, KB

Sorry about that. I guess I was taking it step by step. I didn't realize that chart creation can be so difficult. Any help you can provide will be much appreciated.

Thanks,


William Chadbourne
Programmer/Analyst
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top