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

How to evaluate a value in a formula and based on the result execute another formula -

Status
Not open for further replies.

MrFuzzwah

MIS
Mar 28, 2011
49
US
I have a formula in a subreport that assigns a running total to a variable which is passed to the main report:
// FICA
whileprintingrecords;
shared currencyvar FICA;
FICA:={#FICA}

I have another formula (not a running total) in the main report to calculates another value:
whileprintingrecords;
//CORRECT_FICA
{@CALC3 (TAXBLE-OJI) - NONTAX} * .042

If the result of the first formula is zero the second needs to be zero. I need to look at the result of the first formula and if it is 0 I need to move 0 to the result of the second formula. Notice the second formula does not use any field from the first formula directly.

I can't get it to work. If you can assist - believe me your help is appreciated.
 
The two formulas as distinct - they do not share any fields. But - if the result of the first formula is 0 then the second needs to be zero.
 
You have to reference the shared variable in your second formula, like this:

//CORRECT_FICA
whileprintingrecords;
shared currencyvar FICA;
if FICA=0 then
0 else
{@CALC3 (TAXBLE-OJI) - NONTAX} * .042

-LB
 
I have 2 subreports as shown below:

whileprintingrecords;
shared currencyvar HOURS;
HOURS:=Sum ({PAYROLLDB_EVENT.HOURS});
HOURS

whileprintingrecords;
shared currencyvar RATE;
RATE:={PAYROLLDB_EMP.EMPRATE};
RATE

I'm trying to multiply these two to be inserted into my main report. I have tried to format them in a million ways and move them around to various section with no luck. All I'm trying to do is multiply two values!

whileprintingrecords;
shared currencyvar HOURS;
shared currencyvar RATE;
HOURS * RATE

As usual - does anyone know why this simple thing would not work?

 
Hi MrFuzzwah

What result are you getting?
The calculation must be in a section below the subreports. Are they?
Also, the subreports can not be suppressed - if it is the subreport will not get executed.

In the formula in the main report, change it to display firstly HOURS and then RATE to ensure the values are being returned from the subreports.

Hope this helps

Cheers
Pete
 
Thank for for responding Pete and Lbass. I got is resolved by changing the logic. Actually - it came rather suddenly that I saw a different way to approach it. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top