Crystal Reports - Sum of columns in a group
So I have created the following code snippet to run in a formula to rummate the hours worked for each code in labor...
NumberVar totalHours := SUM({LaborTicket.HoursWorked}, {LaborTicket.VisualCode});
NumberVar totalMinutes := SUM({LaborTicket.HoursWorked}, {LaborTicket.VisualCode}) * 60 MOD 60;
NumberVar totalSeconds := SUM({LaborTicket.HoursWorked}, {LaborTicket.VisualCode}) * 3600 MOD 60;
ToText(totalHours, 0) + ":" +
ToText(totalMinutes, '00') + ":" +
Totext (totalSeconds , '00' 开发者_如何学C)
It converts my representation of 1.50 hours into 1 hour and 30 minutes (or 1:30:00), beautiful.
Now however, they want the report to be by client, by visual code...
Since I need to show total hours for each visual code on one group footer and totals for each client on another group footer, I need to be able to specify to summate based on both of those facts which I'm not sure how to do.
The above function summates ALL clients, not just the one at that point in the report so I need to be able to summate based on the visual code AND client name. Any suggestions?
I'm using the version of crystal that comes with Visual Studio 2010 (well the one you download after installing it)
Ok, so it looks like you simply need to create a new group before the VisualCode group by the Client field. Once you have your two groups, you should be able to go ahead and insert your summary fields by using the new client group. I understand that this summary will show 1.5 instead of your format (1:30:00), but this exercise is just to make sure you are getting the data and then you can change the formatting with your formula once you have the data correct.
Once you have this you should be able to find this new summary field in the field tree of the formula editor under "Report Fields". Then you can change each SUM({LaborTicket.HoursWorked}, {LaborTicket.VisualCode})
part of your formatting function to the new summary field and place it in the same section as the non formatted summary field. To finish it off just suppress the non-formatted summary field so that only your field remains and put it where you need it within the section. I hope this helps.
You need to insert inner group by client name and sum over that group - this automatically groups by all group levels. Or if I have misunderstood and you need sum over client not for different visual codes, then you need to create running total field.
精彩评论