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

Formula Help: Running Total Formula 1

Status
Not open for further replies.

TornierIT

Programmer
Joined
Jan 31, 2008
Messages
14
Location
US
I have been going cross-eyed looking at this and wanted a second set of eyes. I keep getting a "Boolean is required Here". This formula is the 2nd part of the 3-part running total and I wanted to include all the variable into one formula (there would be over 75 formulas if I have to break it apart).

Its crapping out on this part, but it I comment it out, it will crap out on the next section above it:

(
NumberVar PostOpRef_BiomK1 := PostOpRef_BiomK1 + {@Shared_PostOpBiomK1};
NumberVar PostOpRef_BiomK1Count := PostOpRef_BiomK1Count + 1;
)

Crystal XI

WhilePrintingRecords;
If {@Surgery_Type} = "Refraction"
Then
(
If {@Shared_PreOpRefCyc} <> 0 then
(
NumberVar PreOpRef_RefCyc := PreOpRef_RefCyc + {@Shared_PreOpRefCyc};
NumberVar PreOpRef_RefCycCount := PreOpRef_RefCycCount + 1;
)
AND
If {@Shared_PreOpBiomK1} <> 0 then
(
NumberVar PreOpRef_BiomK1 := PreOpRef_BiomK1 + {@Shared_PreOpBiomK1};
NumberVar PreOpRef_BiomK1Count := PreOpRef_BiomK1Count + 1;
)
AND
If {@Shared_PreOpBiomK2} <> 0 then
(
NumberVar PreOpRef_BiomK2 := PreOpRef_BiomK2 + {@Shared_PreOpBiomK2};
NumberVar PreOpRef_BiomK2Count := PreOpRef_BiomK2Count + 1;
)
AND
If {@Shared_PostOpRefCyc} <> 0 then
(
NumberVar PostOpRef_RefCyc := PostOpRef_RefCyc + {@Shared_PostOpRefCyc};
NumberVar PostOpRef_RefCycCount := PostOpRef_RefCycCount + 1;
)
AND
If {@Shared_PostOpBiomK1} <> 0 then
(
NumberVar PostOpRef_BiomK1 := PostOpRef_BiomK1 + {@Shared_PostOpBiomK1};
NumberVar PostOpRef_BiomK1Count := PostOpRef_BiomK1Count + 1;
)
AND
If {@Shared_PostOpBiomK2} <> 0 then
(
NumberVar PostOpRef_BiomK2 := PostOpRef_BiomK2 + {@Shared_PostOpBiomK2};
NumberVar PostOpRef_BiomK2Count := PostOpRef_BiomK2Count + 1;
)
)
else
(
NumberVar PreOpRef_RefCyc := PreOpRef_RefCyc;
NumberVar PreOpRef_RefCycCount := PreOpRef_RefCycCount;
NumberVar PreOpRef_BiomK1 := PreOpRef_BiomK1;
NumberVar PreOpRef_BiomK1Count := PreOpRef_BiomK1Count;
NumberVar PreOpRef_BiomK2 := PreOpRef_BiomK2;
NumberVar PreOpRef_BiomK2Count := PreOpRef_BiomK2Count;
NumberVar PostOpRef_RefCyc := PostOpRef_RefCyc;
NumberVar PostOpRef_RefCycCount := PostOpRef_RefCycCount;
NumberVar PostOpRef_BiomK1 := PostOpRef_BiomK1;
NumberVar PostOpRef_BiomK1Count := PostOpRef_BiomK1Count;
NumberVar PostOpRef_BiomK2 := PostOpRef_BiomK2;
NumberVar PostOpRef_BiomK2Count := PostOpRef_BiomK2Count
)

 
Put all the Numbervar's at the top before you start the IF.
 
Same error message. I even removed all the other NumberVar's after it was declared
 
Can we assume you are creating manual running totals?

The "And's" don't belong there. Each clause where you are using "and" should end with a semicolon instead. The variable declarations belong at the beginning, and I think you should be referencing any shared variables directly rather than formulas containing them.

You might be better off explaining what you are trying to do, and if you are using shared variables, you need to explain where the subreport is that establishes the value of the shared variables, identify the section where you are then trying to reference them, and also show the content of the shared variable formulas (or at least one or two of them).

-LB
 
MY APOLOGIES:

Yes, this is a 3-part Manual Running Total (I think Malcolm had the FAQ for it)

Yes, i am using shared variables from a subreport which is placed in a group footer above this formula.

I have used these many time when one condition is met, but now that I have multiple conditions, I am having issues. The first condition must be met:

If {@Surgery_Type} = "Refraction"

But the following conditions can have none to all of them met, but each needs its own separate IF THEN statement. If I use an ELSE on the first statement then the remaining conditions will not have a chance to be met.

I am just trying to cut corners here, if I use this formula, it works fine, but I will need 6 formula fields for 6 criteria (with more in the future), so I am trying to cut it down to only 6 formula fields, with these IF statements.

I had a hunch the AND is irrelevant, but I am not sure how to allow all the conditions to be tested.

Thanks in advance..

Oh, forgot this, here is the content of a shared variable formula in the subreport (I tested it using the formulas I used above and just thought I would leave them in this formula, I typically just reference them directly)

WhilePrintingRecords;
Shared NumberVar PreOpBiomK1 := {#Avg_PreOp_BiomK1}
 
If you need more help, please show the resulting formula after you have applied the earlier suggestions.

-LB
 
I am just trying to cut corners here, if I use this formula, it works fine, but I will need 6 formula fields for 6 criteria (with more in the future), so I am trying to cut it down to only 6 formula fields, with these IF statements."

the is the formula I was talking about in this sentence:

WhilePrintingRecords;

NumberVar PreOpRef_RefCyc;
NumberVar PreOpRef_RefCycCount;

If {@Surgery_Type} = "Refraction"
THEN
If {@Shared_PreOpRefCyc} <> 0 and Not(IsNull({@Shared_PreOpRefCyc})) then
(
PreOpRef_RefCyc := PreOpRef_RefCyc + {@Shared_PreOpRefCyc};
PreOpRef_RefCycCount := PreOpRef_RefCycCount + 1;
)
 
I was referring to the extended formula.

-LB
 
HERE IT IS SO FAR.. CAN YOU PLEASE EXPLAIN THE "AND" AND SEMICOLON PART YOU MENTIONED:

WhilePrintingRecords;

NumberVar PreOpRef_RefCyc;
NumberVar PreOpRef_RefCycCount;
NumberVar PreOpRef_BiomK1;
NumberVar PreOpRef_BiomK1Count;
NumberVar PreOpRef_BiomK2;
NumberVar PreOpRef_BiomK2Count;
NumberVar PostOpRef_RefCyc;
NumberVar PostOpRef_RefCycCount;
NumberVar PostOpRef_BiomK1;
NumberVar PostOpRef_BiomK1Count;
NumberVar PostOpRef_BiomK2;
NumberVar PostOpRef_BiomK2Count;
Shared NumberVar PreOpBiomK1;
Shared NumberVar PreOpBiomK2;
Shared NumberVar PreOpRefCyc;
Shared NumberVar PostOpBiomK1;
Shared NumberVar PostOpBiomK2;
Shared NumberVar PostOpRefCyc;


If {@Surgery_Type} = "Refraction"
THEN
If PreOpRefCyc <> 0 then
(
PreOpRef_RefCyc := PreOpRef_RefCyc + PreOpRefCyc;
PreOpRef_RefCycCount := PreOpRef_RefCycCount + 1;
)
AND
If PreOpBiomK1 <> 0 then
(
PreOpRef_BiomK1 := PreOpRef_BiomK1 + PreOpBiomK1;
PreOpRef_BiomK1Count := PreOpRef_BiomK1Count + 1;
)
AND
If PreOpBiomK2 <> 0 then
(
PreOpRef_BiomK2 := PreOpRef_BiomK2 + PreOpBiomK2;
PreOpRef_BiomK2Count := PreOpRef_BiomK2Count + 1;
)
AND
If PostOpRefCyc <> 0 then
(
PostOpRef_RefCyc := PostOpRef_RefCyc + PostOpRefCyc;
PostOpRef_RefCycCount := PostOpRef_RefCycCount + 1;
)
AND
If PostOpBiomK1 <> 0 then
(
PostOpRef_BiomK1 := PostOpRef_BiomK1 + PostOpBiomK1;
PostOpRef_BiomK1Count := PostOpRef_BiomK1Count + 1;
)
AND
If PostOpBiomK2 <> 0 then
(
PostOpRef_BiomK2 := PostOpRef_BiomK2 + PostOpBiomK2;
PostOpRef_BiomK2Count := PostOpRef_BiomK2Count + 1;
)
 
Disregard Lbass. Its been a long day for me. WORKED LIKE A CHARM

Much appreciated
 
If it matters to anyone else. here is my final formula:

WhilePrintingRecords;

NumberVar PreOpRef_RefCyc;
NumberVar PreOpRef_RefCycCount;
NumberVar PreOpRef_BiomK1;
NumberVar PreOpRef_BiomK1Count;
NumberVar PreOpRef_BiomK2;
NumberVar PreOpRef_BiomK2Count;
NumberVar PostOpRef_RefCyc;
NumberVar PostOpRef_RefCycCount;
NumberVar PostOpRef_BiomK1;
NumberVar PostOpRef_BiomK1Count;
NumberVar PostOpRef_BiomK2;
NumberVar PostOpRef_BiomK2Count;
Shared NumberVar PreOpBiomK1;
Shared NumberVar PreOpBiomK2;
Shared NumberVar PreOpRefCyc;
Shared NumberVar PostOpBiomK1;
Shared NumberVar PostOpBiomK2;
Shared NumberVar PostOpRefCyc;


If {@Surgery_Type} = "Refraction"
THEN
If PreOpRefCyc <> 0 then
(
PreOpRef_RefCyc := PreOpRef_RefCyc + PreOpRefCyc;
PreOpRef_RefCycCount := PreOpRef_RefCycCount + 1;
);
If PreOpBiomK1 <> 0 then
(
PreOpRef_BiomK1 := PreOpRef_BiomK1 + PreOpBiomK1;
PreOpRef_BiomK1Count := PreOpRef_BiomK1Count + 1;
);
If PreOpBiomK2 <> 0 then
(
PreOpRef_BiomK2 := PreOpRef_BiomK2 + PreOpBiomK2;
PreOpRef_BiomK2Count := PreOpRef_BiomK2Count + 1;
);
If PostOpRefCyc <> 0 then
(
PostOpRef_RefCyc := PostOpRef_RefCyc + PostOpRefCyc;
PostOpRef_RefCycCount := PostOpRef_RefCycCount + 1;
);
If PostOpBiomK1 <> 0 then
(
PostOpRef_BiomK1 := PostOpRef_BiomK1 + PostOpBiomK1;
PostOpRef_BiomK1Count := PostOpRef_BiomK1Count + 1;
);
If PostOpBiomK2 <> 0 then
(
PostOpRef_BiomK2 := PostOpRef_BiomK2 + PostOpBiomK2;
PostOpRef_BiomK2Count := PostOpRef_BiomK2Count + 1;
);
 
Are all of the separate clauses supposed to be based on the condition:

If {@Surgery_Type} = "Refraction" THEN

??? If so, the formula should have an extra set of parens:

WhilePrintingRecords;

NumberVar PreOpRef_RefCyc;
NumberVar PreOpRef_RefCycCount;
NumberVar PreOpRef_BiomK1;
NumberVar PreOpRef_BiomK1Count;
NumberVar PreOpRef_BiomK2;
NumberVar PreOpRef_BiomK2Count;
NumberVar PostOpRef_RefCyc;
NumberVar PostOpRef_RefCycCount;
NumberVar PostOpRef_BiomK1;
NumberVar PostOpRef_BiomK1Count;
NumberVar PostOpRef_BiomK2;
NumberVar PostOpRef_BiomK2Count;
Shared NumberVar PreOpBiomK1;
Shared NumberVar PreOpBiomK2;
Shared NumberVar PreOpRefCyc;
Shared NumberVar PostOpBiomK1;
Shared NumberVar PostOpBiomK2;
Shared NumberVar PostOpRefCyc;


If {@Surgery_Type} = "Refraction"
THEN [red]([/red]
If PreOpRefCyc <> 0 then
(
PreOpRef_RefCyc := PreOpRef_RefCyc + PreOpRefCyc;
PreOpRef_RefCycCount := PreOpRef_RefCycCount + 1;
);
If PreOpBiomK1 <> 0 then
(
PreOpRef_BiomK1 := PreOpRef_BiomK1 + PreOpBiomK1;
PreOpRef_BiomK1Count := PreOpRef_BiomK1Count + 1;
);
If PreOpBiomK2 <> 0 then
(
PreOpRef_BiomK2 := PreOpRef_BiomK2 + PreOpBiomK2;
PreOpRef_BiomK2Count := PreOpRef_BiomK2Count + 1;
);
If PostOpRefCyc <> 0 then
(
PostOpRef_RefCyc := PostOpRef_RefCyc + PostOpRefCyc;
PostOpRef_RefCycCount := PostOpRef_RefCycCount + 1;
);
If PostOpBiomK1 <> 0 then
(
PostOpRef_BiomK1 := PostOpRef_BiomK1 + PostOpBiomK1;
PostOpRef_BiomK1Count := PostOpRef_BiomK1Count + 1;
);
If PostOpBiomK2 <> 0 then
(
PostOpRef_BiomK2 := PostOpRef_BiomK2 + PostOpBiomK2;
PostOpRef_BiomK2Count := PostOpRef_BiomK2Count + 1;
)
[red])[/red];

-LB


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top