crystal-reportscrystal-reports-2016

Crystal Reports 2016 Sum field on two groups


I have a report that sums data and I am trying to modify it. I am trying to break out the totals by week by machine instead of one grand total by machine. Example of the calculations look like the following:

numberVar x := Sum ({WorkCntrSummary.Downtime_DurationInMinutes_Category0}, {WorkCntrSummary.Criteria_MachineID});
numberVar xh := Truncate(Round(x)/60);
numberVar xm := Round(x) mod 60;

if xh >= 1 then
  ToText (xh, 0) + "h " + ToText (xm, 0) + "m"
else
  ToText (xm, 0) + "m"

I am trying to change the 1st line where it is summing the field by MachineID. I want to sum it on the MachineID and also on a different group I added to the report which is a date field grouped by week. I am at a loss as to how to change that sum to add the date field by week to it. I tried changing it to the following, which doesn't do anything with grouping by week.

numberVar x := Sum ({WorkCntrSummary.Downtime_DurationInMinutes_Category0}, {WorkCntrSummary.Criteria_MachineID},{WorkCntrSummary.Criteria_StartDateTime});
numberVar xh := Truncate(Round(x)/60);
numberVar xm := Round(x) mod 60;

if xh >= 1 then
  ToText (xh, 0) + "h " + ToText (xm, 0) + "m"
else
  ToText (xm, 0) + "m"

But I get an error group condition must be a string.

Any help would be much appreciated. Thanks!


Solution

  • Change

    Sum ({WorkCntrSummary.Downtime_DurationInMinutes_Category0}, {WorkCntrSummary.Criteria_MachineID},{WorkCntrSummary.Criteria_StartDateTime})
    

    to

    Sum ({WorkCntrSummary.Downtime_DurationInMinutes_Category0}, {WorkCntrSummary.Criteria_StartDateTime})
    

    In Crystal, the 2nd argument is what you group on. No need to chain all the grouping elements.