Add “Total” per row and column in Crystal Reports without CrossTab

﹥>﹥吖頭↗ 提交于 2019-12-01 08:35:40

问题


I have a simple question.

Suppose I have a Stored Proceudre that returns a table with the following columns: (Item, GreenColour, RedColour), corresponding to all the possible Items and how many of them are "Green" or "Red". i.e, a possible output could be {(Apple, 4, 2), (Chair, 1, 2)}.

What I want to do in the report is the following:

In the header section, write four columns: "Item", "Green", "Red" and "Total"; where "Total" corresponds to the total per row. Then in the "Details" section adding the "GreenColour", "RedColour" and some other "TotalColours" field (Which I don't know well). And also adding an additional line at the bottom with the totals per column.

This sounds very similar to the "CrossTab" tool, but it can't be done that way. I know a possible answer is modifying the StoredProcedure by adding the "Total" column and compute it in the query. And adding the "Total" per column with a UNION after the query, where "Item" is "Total" and values of "Green" and "Sum" are "SUM" of another query. But I don't want to do it this way, I want Crystal Reports to solve it.

Thanks and I apologize of writing so much for asking such a simple question.

Edit: The wanted output for my example would be:

Item      Green Colour    Red Colour    Total
Apple          4              2           6
Chair          1              2           3
Total          5              4           ¿9?

Also would like to know if it's possible to make both ways with the '9' and without it.


回答1:


You're right, crosstabs are overkill for this. Just create a formula to sum the colors:

{table.GreenCount} + {table.RedCount}

To get the report totals (the 9 in your example), just insert a summation summary. (Right-click the formula field you just created -> "Insert" -> "Summary" -> "Calculate this summary" as Sum).



来源:https://stackoverflow.com/questions/10567625/add-total-per-row-and-column-in-crystal-reports-without-crosstab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!