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!

main report not adding subreport totals by groups together

Status
Not open for further replies.

marylally

Technical User
May 15, 2009
37
US
I have a report with a subreport. The sub report is grouped by empid and payweek. the main report is also grouped the same way. I created a formua in the sub that passes to the main. On the main report it calculates correctly for each empid and payweek.

My problem is when I try to add the formula for each group and pass it to the main report I only get the second record from the payweek group.

Ex:

Empid 2007
Week 28 vpg $800.00
Week 29 vpg $1776.00

Total vpg $1776 it should be $2576.00

Please help!!!
THanks, Mary




MaryBeth
 
Values passed as Shared Variables are only available in the section below the section that calls the subreport. Sometimes it's best to split a section to get round this.

Does that help?

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 11.5 with SQL and Windows XP [yinyang]
 
Unfortunately no.

I added an additional footer and placed it there and it still picks up only the second record for a total.

Here's my formula for vpgpass in subreport:

whileprintingrecords;
shared currencyvar vpgpass := {@VPG}

here's the one in my main report avgvpg:

whileprintingrecords;
shared currencyvar vpgpass;
currencyvar avgvpg;
Avgvpg := vpgpass;
avgvpg


MaryBeth
 
MaryBeth

You subreport formula will only pick up the last value of {@vpg}

You need to change to

whileprintingrecords;
shared currencyvar vpgpass := sum({@VPG})

Assuming SR is linked on Employee id

Ian
 
I just tried that and if tells me the field can't be summarized?

MaryBeth
 
Ian,

vpg:

whileprintingrecords;
shared Currencyvar totala;
shared numbervar tourb;
currencyvar VPG;
VPG := if tourb = 0 then 0 else totala/tourb;
VPG

i have this in the sub looking at the main report field totala and tourb

Thanks, Mary

MaryBeth
 
Change to

whileprintingrecords;
shared Currencyvar totala;
shared numbervar tourb;
currencyvar VPG;

If Tourb <> 0 then
VPG := vpg + (totala/tourb);
VPG
 
Ian,

It still only brings back the 1776.

Mary

MaryBeth
 
MaryBeth,

You need to explain the group structure of your main report, explain in what section the subreport is located in the main report, and how it is linked to the main report. You should also explain whether both 'totala' and 'tourb' are coming from shared variables established in the main report, and if so, then show the content of those formulas and explain where they are located in the main report. Of course, if both variables are coming from the main report, there is no reason to be working with them in the subreport that I can see.

-LB
 
I lB,

I was able to add an additional sub report and pull the next second record to get my value. It takes the report longer to run but worked.

Thanks for your help!
MaryBeth

MaryBeth
 
New Problem:

I thought I solved the problem but now I my new formula field is adding the @test value for each employee.

Emp 1 vpgpass $ 1288.
Emp 2 @vpgpass $3446.

should be $2158. but this is adding 1288. to 2158. to get a value of 3446.

@test= whileprintingrecords;
shared currencyvar test :={@vpg};

@vpgpass =WhilePrintingRecords;
Shared currencyVar test/2;

How can I get it to deduct the previous value?

Please help,
MaryBeth

MaryBeth
 
Please respond to the questions in my last post.

-LB
 
Hi LB,

Group 1 Emp_Id in Main report and sub report
Group 2 @Week in Main and Sub

tourb in main report located in GF3 Main: WhilePrintingRecords;Shared numberVar tourb := Count ({@in period counter}, {PAYABLES_LEDGER.PAY_WK})

totala in sub located in GF3 Main: WhilePrintingRecords;Shared CurrencyVar totala := Sum ({Command.salesvolume})

VPG in sub located in sub : whileprintingrecords;
shared Currencyvar totala;
shared numbervar tourb;
currencyvar VPG;

If Tourb <> 0 then
VPG := vpg + (totala/tourb);
VPG

vpgpass located in sub whileprintingrecords;
shared currencyvar vpgpass := {@VPG}

and vpgpass located in Main to bring over @VPG




MaryBeth
 
You haven't identified your group #3 or explained how the sub is linked to the main report.

-LB
 
I don't have a group 3

Sorry I forgot the links,

the reports are linked by emp_id and Week number

Mary

MaryBeth
 
tourb in main report located in [red]GF3[/red] Main:"

"ttotala in sub located in [red]GF3[/red] Main:"

What you are trying to do is not that complicated, but we need to understand your report setup clearly.

Can I assume that "week number" = {@Week}?

-LB
 
Yes, you are correct. I can enter 2 weeks at a time to get an average of the 2 weeks for each employee

Mary

MaryBeth
 
Your response is non-responsive. Please correct your post where you are referring to GF3, as I don't have a clue what you mean.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top