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

Trying to summarize Formulas that also summarize

Status
Not open for further replies.

Jimdeb03

IS-IT--Management
Dec 10, 2002
89
US
My report summarizes many records per EmployeeID. Certain fields are simply Summarized while others a calculation is performed via a Formula in the Group Footer.

Details @SumHours_ALL
Details @SumHours_ALL
Details... @SumHours_ALL
Group Footer #3 @CalculateDays @SumDays
Details @SumHours_ALL
Details @SumHours_ALL
Details... @SumHours_ALL
Group Footer #3 @CalculateDays @SumDays
Group Footer #1 <Want to summarize @CalculateDays here>

Now we need to add a Summary of @DaysCalculate in Group Footer #1 but goto Insert/Summary and @DaysCalculate is not avaiable to Sum.

I'm found thread thread767-1402814 Summary on a Formula as a guide but it doesn't want to Sum all Formulas in GF#3, it only displays the last.

@CalculateDays
Global NumberVar gCalculateDays;
WhilePrintingRecords;
gCalculateDays = ({@SumHours_ALL}/ToNumber({SPROC;1.HrsPerDay}));

@SumDays
WhilePrintingRecords;
global NumberVar gCalculateDays := gCalculateDays;

@TotalDays
WhilePrintingRecords;
global NumberVar gCalculateDays := {@SumDays} ;
or
global NumberVar gCalculateDays := gCalculateDays;
(Same result)

@ResetTotalDays
WhilePrintingRecords;
global NumberVar gCalculateDays := 0;

I tried @ResetTotalDays in GF #1, GF #2 with no difference.
@CalculateDays, @SumDays work fine.
Tried @SumDays and @TotalDays in GF3, GF2 and GF1 with no difference. All different scenarios I can think of were tried but without any luck.

Anyone have any ideas? It's gotta be simpler than this to summarize fields















Why are some Formulas available to Summarize but not all?

So I try and create a Formula in Group Footer #1 ...
Sum ({@DaysCalculate},{SPROC;1.Tier} );
and get a 'Field Cannot be summarized' error

Usually if I want a summary in GF #1, I would summarize all Detail fields within GF#1 completely bypassing the Formulas in GF#3 because they're simply database field and can be summarized.

Summing formulas via the Sum() function doesn't work so am at a standstill

So I tried setting a Global Variable in @DaysCalculate but cannot pass it into another formula even as a test.

Formula @DaysCalculate
WhilePrintingRecords;
Global NumberVar gCalculateDays;
gCalculateDays := 99;

Formula @SumDays
WhileReadingRecords;
NumberVar gCalculateDay;
gCalculateDays := gCalculateDays + 1;


Formula @SumDays doesn't reflect Global Variable gCalculateDays

CR help is vague with explaining Global Variables.
They give this example...
//Formula C
Global NumberVar x;
x := 10;

//Formula D
//Call the function WhileReadingRecords
WhileReadingRecords;
Global NumberVar x;
x := x + 1

I put these in a Blank Report in the Report Header and Detail Section respectively. But it doesn't work as expected.
Formula D returns nothing, C has 10

 
**Sorry! This is a cleaner, shorter version of the first entry.

My report summarizes many records per EmployeeID. Certain fields are simply Summarized while others a calculation is performed via a Formula in the Group Footer.

Details @SumHours_ALL
Details @SumHours_ALL
Details... @SumHours_ALL
Group Footer #3 @CalculateDays @SumDays
Details @SumHours_ALL
Details @SumHours_ALL
Details... @SumHours_ALL
Group Footer #3 @CalculateDays @SumDays
Group Footer #1 <Want to summarize @CalculateDays here>

Now we need to add a Summary of @DaysCalculate in Group Footer #1 but goto Insert/Summary and @DaysCalculate is not avaiable to Sum.

I'm found thread thread767-1402814: summary on a formula Summary on a Formula as a guide but it doesn't want to Sum all Formulas in GF#3, it only displays the last.

@CalculateDays
Global NumberVar gCalculateDays;
WhilePrintingRecords;
gCalculateDays = ({@SumHours_ALL}/ToNumber({SPROC;1.HrsPerDay}));

@SumDays
WhilePrintingRecords;
global NumberVar gCalculateDays := gCalculateDays;

@TotalDays
WhilePrintingRecords;
global NumberVar gCalculateDays := {@SumDays} ;
or
global NumberVar gCalculateDays := gCalculateDays;
(Same result)

@ResetTotalDays
WhilePrintingRecords;
global NumberVar gCalculateDays := 0;

I tried @ResetTotalDays in GF #1, GF #2 with no difference.
@CalculateDays, @SumDays work fine.
Tried @SumDays and @TotalDays in GF3, GF2 and GF1 with no difference. All different scenarios I can think of were tried but without any luck.

Anyone have any ideas? It's gotta be simpler than this to summarize fields
 
You need to set it up like this to add:

@SumDays to be placed in GF#3:
WhilePrintingRecords;
NumberVar gCalculateDays := {@SumHours_ALL}/ToNumber({SPROC;1.HrsPerDay});
numbervar sumcalcdays := sumcalcdays + gCalculateDays;

The reset in GH#1 would be:
WhilePrintingRecords;
numbervar sumcalcdays;
if not inrepeatedgroupheader then
sumcalcdays := 0;

The display formula in the group #1 footer would be:
WhilePrintingRecords;
numbervar sumcalcdays;

If you want summaries at different group levels, you need to use different variables. Note also that there is no need to specify "global" as that is the default.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top