home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / dbase / tn9101.arj / SUMSUMM.TXT < prev    next >
Encoding:
Text File  |  1991-03-05  |  3.7 KB  |  82 lines

  1.  
  2. This article is reprinted from the January 1991 edition of
  3. TechNotes/dBASE IV.  Due to the limitations of this media, certain
  4. graphic elements such as screen shots, illustrations and some tables
  5. have been omitted.  Where possible, reference to such items has been
  6. deleted.  As a result, continuity may be compromised.  
  7.  
  8. TechNotes is a monthly publication from the Ashton-Tate Software
  9. Support Center.  For subscription information, call 800-545-9364.
  10.  
  11. Summed Summaries
  12. Joel Saltzman
  13.  
  14. The normal function of summary fields in dBASE IV reports is to
  15. aggregate data from individual records in a database or view. 
  16. However, there can be times when one would like to summarize group
  17. summary information.  Consider these two examples: a sales manager who
  18. wants to average the number of separate sales for each salesperson and
  19. a production foreman who wants to see the work group that has produced
  20. the most units.  At first look, the report generator appears that it
  21. would have a difficult time producing the summary of group summaries. 
  22. But it can be done, without any modification to the REPORT.COD
  23. template file or the dBASE IV source code file (the name of your
  24. report with the .FRG extension).
  25.  
  26. 1.              First you need to create a grouped report which contains a
  27. summary field in the group summary band.  The summary field must have
  28. a name (you are allowed to have unnamed summary and calculated fields)
  29. and may be either hidden or visible.
  30.  
  31. 2.              Create a hidden calculated field in the group summary band. 
  32. The caclulated field must have a unique name.  The expression for this
  33. caclulated field will be the name of the summary field created in step
  34. 1.
  35.  
  36. 3.              In the Report summary band, create a summary field.  The field
  37. to summarize on will be the hidden calculated field defined in step 2.
  38.  
  39. Now we can apply this method to our examples.  For the first scenario,
  40. the sales manager report, index the database by salesperson.  Each
  41. record in the database represents one sale.  Group the report by
  42. salesperson.  In the Group Summary band, create a summary field with
  43. the operation of "COUNT".  For this example,  the field is given the
  44. name "CNTSALE1".  
  45.  
  46. Next, create a hidden calculated field by the name of "CNTSALE2" in
  47. the Group Summary band. The expression for this new field will be
  48. CNTSALE1, which contains the number of sales for a salesperson.  In
  49. the report summary band, create a summary field with the "AVERAGE"
  50. operation.  The field to summarize on will be CNTSALE2, the hidden
  51. calculated field from the group summary band.
  52.  
  53. The second scenario would involve first indexing the database by a
  54. field such as the work group code shown in the simple database
  55. structure below.  
  56.  
  57. Field Name              Type    Length          Decimals        Index
  58.  
  59.  
  60. WORK_GROUP              C               15                              
  61. Y
  62. PRODUCTION              N               10                              2
  63. N
  64. ...
  65.  
  66. The report should be grouped by this indexed field.  A summary field,
  67. "SUMGRP1", will be created in the Ggroup Summary band with the "SUM"
  68. operation.  The next step is to create "SUMGRP2", a hidden calculated
  69. field also in the Group Summary band.  The expression for this field
  70. will be SUMGRP1, which represents the total production for a work
  71. group.  We now move to the Report Summary band.  You can now create a
  72. summary field, using the "MAX" operation to find the greatest of each
  73. work group's total production. Use SUMGRP2 as the field to summarize
  74. on.
  75.  
  76. This is just another example of the wonderful uses of calculated
  77. fields in reports to accomplish difficult tasks.  With a little
  78. applied innovation, there are undoubtedly many tasks you can handle. 
  79. s
  80.  
  81.  
  82.