Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sum a field by week

Status
Not open for further replies.

TimGoff

Technical User
Jul 16, 2002
166
GB
Hello,

I have two fields - date & duration

I would like to have a table in the bottom of my report (the report shows each line) showing the duration summed by week.

Is this possible?

Many thanks
Tim
 
Yes, when you group by a date or date-time field, Crystal has a drop down list indicating how often you want the data grouped. Pick weekly.

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports
 
If you group, you can get totals for each week along with the detail records.

If you want all of the detail lines, and then a set of weekly totals, you could do it using running totals, but that would be a lot of work. Better to put a subreport in the report footer and have the details suppressed, with just the totals. Depending on your data, this might be best done by a crosstab.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
[yinyang] Windows XP & Crystal 10 [yinyang]
 
It sounds like you want a summary at the end of the report. I would insert a crosstab in the report footer. Use {table.date} as the row field and while it is highlighted->group options->select print on change of week. Then add sum of duration as the summary field.

-LB
 
Cross tab does it perfectly - thanks everyone for your help
Tim
 
Hello
The cross table is working great for the durations but what i also want is percentages too. I want subtitled duration grouped by week - and as a percentage of the total duration

So i have



Date(by week) Subtitled Duration %age
Total duration 100%

The only option I have though is subtitled duration as a percentage of itself.

Is this possible?

Thanks in advance
Tim
 
What version of CR are you using?

-LB
 
If you are using a higher version of CR, like CR XI, you can create a formula:

{table.duration} % sum({table.duration})

Insert this as a summary field, choosing sum as the summary. Then in preview mode, select the inner and total cells and click on the % icon in the toolbar.

-LB

 
Hi - i'm only using CR9 unfortunately.
Is there anything i can do in that ?
Cheers
Tim
 
I am not familiar with CR 9. Did you try the above (which works in 11.0)? Let me know if it doesn't work, and I will suggest a different solution.

-LB
 
I've only got 9 - and I need to embed the reports into an application that only supports 9 so wouldn't be able to upgrade unfortunately.
Sorry LB - thanks for your patience.
Tim
 
Tim, you still haven't said whether you tried the formula I suggested. It might work in 9.0--I'm just not sure. You need to tell me.

-LB
 
I guess I should assume it didn't work. Again, I'm not sure how SQL expressions work in 9.0, but if you have the option of using one, try creating the following {%sumall}:

(select sum(table.`duration`) from table)

If you have selection criteria, they would need to be built into the SQL expression.

Then create a formula {@percent}:

{table.duration} % {%sumall}

Add this as a summary field, using sum as the summary.

If the SQL expression doesn't work correctly, you could also return the sum of duration by using "Add Command" as your datasource.

-LB
 
Still fiddling actually!
Thanks for your latest suggestion, i'll give it a go...
Cheers
Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top