Search code examples
crystal-reportsfield

How do I insert a sum of a field into Text Object in Crystal Reports?


I'm working on a report that was made before I started working here and the person who originally made it is gone. As such, I don't know how he made what he made, which is this:

There is a set of Text Objects which hold summary fields (for instance, the text inside one is "{Sum of Job.ServiceCharge}", quotes omitted but braces are actually there). I can drag and drop Job.ServiceCharge into a Text Object, but it's not a summary. I can create a summary of Job.ServiceCharge, but that's not in a Text Object. I can create a Running Total Field of Job.ServiceCharge and put that in a Text Object, but none of the fields that he did show up in the list of Running Total Fields, so that can't be the way he did it.

Does anybody know how this can be done?


Solution

  • If the field you're summarizing is a string then you can just create the summary like you normally would ('Insert' -> 'Summary' -> Set up your summary) and then drag it from where it was inserted into your report into your text field.

    If the field is not a string then you will have to convert it into a string first via a formula. So say you want to display the sum of your service charges for the entire report. You would create a formula like this: totext(sum({Job.ServiceCharge})) Then, you can just drag that formula into the text field that you want.

    If you want to sum over groups, check the CR help for how to use summary functions in formulas.

    Edit 1 Actually, that second part is not true. You shouldn't even need to convert to embed it into a text field. You would just format it how you wanted it like any numeric field on your report.