Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Best way to do calculations...
Message
De
01/09/1999 19:40:00
Cindy Winegarden
Duke University Medical Center
Durham, Caroline du Nord, États-Unis
 
 
À
01/09/1999 18:17:50
Peter Brama
West Pointe Enterprises
Detroit, Michigan, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire de rapports & Rapports
Divers
Thread ID:
00260385
Message ID:
00260405
Vues:
28
Peter,

The absolutely most reliable way to do reports in Fox is to select the data into a cursor. Printing from related tables is a debugging nightmare.

Do like this:
SELECT Log.Client, ;
    SUM(IIF(Code.BillingRecord, Log.LogAmount, 0) AS TotalBilling, ;
    SUM(IIF(Code.CollectionRecord, Log.LogAmount, 0) AS TotalCollection, ;
    SUM(IIF(Code.WriteOffRecord, Log.LogAmount, 0) AS TotalWriteOff, ;
    FROM Log, Code ;
    INTO MyReportCursor ;
    GROUP BY Log.Client
Now, if you are showing the detail lines, just SELECT the Client, Code, and Amount into the cursor. Then create report variables where the value to store is the IIF statement as above and reset when the Client changes.

I do a lot of these reports and these methods are reliable. It's easy to debug when you have the exact data in a cursor and you can SUM in the command window to check the math.

>I am writing a report that has 3 columns.... BILLING, COLLECTIONS, WRITEOFF... this report is to list the totals per client for these three columns based off records entered in a file I call LOG which is a transaction type file. The log file, in addition to storing dates and user, etc, stores a code ID and and amount. The code ID links to a master CODE file that stores the type of code it is (Billing, Collection, Writeoff, etc).
>
>Here is the scenario I am attempting to accomplish. Per client, I need to SUM all the LOG records whose matching code.type=Billing and place that in the BILLING column. Then I need to SUM all the LOG records whose matching code.type="Collection" and place that in the COLLECTIONS column, and finally the same for WRITEOFF.
>
>Currently, I tried just adding the files to the DE on the report, linking via the appropriate linking fields (ID's), and have a GROUP defined for the CLIENTID... I placed the actual fields in the GROUP FOOTER so that I wouldn't have a record listed for each LOG entry.
>
>Now the problem comes with the summing steps. I am not sure if I am overlooking something in the report writer for doing this (a specific EXPRESSION for a field and/or the CALCULATIONS section of a field or what. Nor am I sure if instead I should create a SELECT cursor before running the report and build the report of the cursor. Is this another one of those VFP items that have multiple ways of accomplishing it or is one the proper, correct, or only way of handling this.
>
>Thanks
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform