Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sum of field based on date
Message
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01154432
Message ID:
01155888
Views:
5
Yes, you have understand the problem correctly.

I have already found solution before you posted your solution here (sorry that I haven't seen it until today).

It is similar but simpler.

I have created variable X and set expression to the SOMENUMBER field, Calculate option to SUM and RESET point to End of Report.

In Group Footer then I have put field with expression X-SOMENUMBER.

And that's it.

Explanation is simple. X is sum of all prior and current numbers that will always be subtracted by current value of SOMENUMBER (simple language explanation (PRIOR + CURRENT) - CURRENT = PRIOR)

Of course, condition must be that table used is sorted by date.


>>I have a table used in report with two fields SOMEDATE and SOMENUMBER.
>>
>>I have made group by SOMEDATE in report.
>>
>>I want in group footer to show total SUM of SOMENUMBER for dates before date that is current in group.
>>
>>How to do that? (preferably it would be variable)
>
>First, let me make sure I completely understand what you want. If you have the following data ... you want to see the following subtotals ...
>
>1/1/06      10
>            20
>            --
>This Total: 30   Prior Total: 0
>
>1/2/06       5
>            10
>            15
>            --
>This Total: 30   Prior Total: 30
>
>1/3/06      15
>            20
>             5
>            --
>This Total: 40   Prior Total: 60
>
>
>Okay .. so assuming I understand your problem and you are looking for the "Prior Total" I showed above, here's how to do it.
>
>1. Create a report variable called rnGrandTotal, set the expression to the SOMENUMBER field, set the Calculate option to SUM, and set the RESET point to End of Report.
>
>2. Create another report variable called rnPriorTotal, set the expression to 0, set the calculate option to SUM, and set the RESET point to End of Report. (By itself, this would yield zero at the end of the report .. but I'm not done yet so don't get worried yet)
>
>3. In the On Exit Expression of the Group Footer band, put the following expression:
>
>_VFP.SetVar('rnPriorTotal', rnGrandTotal)
>
>
>4. Use rnPriorTotal in the Group Footer band to show the prior total.
Previous
Reply
Map
View

Click here to load this message in the networking platform