Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Carry forward a group total
Message
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
01342833
Message ID:
01343383
Views:
20
>>>Is there a way to carry a group total (calculated in the group footer) forward into the footer for the next group so that it can be used in a calculation to provide the % change between the 2 groups?
>>>
>>>Suppose the report is grouped on year, with columns for each month. In the footer for 2008 we want the calculate the % change for jan08 over jan07.
>>>
>>>IE result = (jan08grouptotal - jan07grouptotal) / jan07grouptotal
>>>
>>>Thanks
>>
>>
>>Let's say you need 12 totals .... one for each month ...
>>
>>Create 24 report variables; rnJanPrev, rnFebPrev, ... rnDecPrev, rnJanCurr, rnFebCurr, ... rnDecCurr. For the "Prev" variables, set the initial value to 0, set the expression to 0, set the calculate option to SUM and have them reset at end of report. For the "Curr" variables, set the initial value to 0, the expression to whatever field you need, and reset at the data group.
>>
>>In the OnExit expression of the data group footer enter this:
>>
>>
>>_VFP.SetVar('rnJanPrev', rnJanCurr) AND _VFP.SetVar('rnFebPrev', rnFebCurr) AND ... _VFP.SetVar('rnDecPrev', rnDecCurr)
>>
>>
>>In the data group footer, print (rnJanCurr - rnJanPrev) / rnJanPrev ... and so on.
>
>I think he tried this and it didn't work. Also you can not use AND with _VFP.SetVar, you need to use NVL function here...

AND works just fine for me without any NVL. I can combine as many SetVar()s as I want in the OnExit expression.

If it didn't work for him my guess is that he forgot to mark the previous variables as calculate SUM and reset it at end of report. That's the biggest mistake I see people make when trying to implemenbt this trick.
Cathy Pountney, Microsoft Visual FoxPro MVP
Memorial Business Systems, Inc. (www.mbs-intl.com)

My Website: (www.frontier2000.com)
My Blog: (www.cathypountney.blogspot.com)
My Book: The Visual FoxPro Report Writer - Pushing it to the Limit and Beyond
Free MSDN Article: What's New in the VFP 9.0 Report Writer
Free MSDN Article: The VFP 9.0 Report Writer In Action
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform