Crystal Reports putting a group in different colum

2019-06-09 13:12发布

问题:

I'm trying to take one group and put it in two different columns. I know you can do that for the details of a group in the section expert but it won't allow you do so for a group. The group is date that I've separated by months for the all of last year and this year to the current date and I want last year's months in one column and this year's months in another column. Like this:

    January 2011             January 2012
    February 2011            February 2012
    March 2011               March 2012
    April 2011               April 2012
    May 2011
    June 2011
    July 2011
    August 2011
    September 2011
    October 2011
    November 2011
    December 2011

That way the months are easy to compare and they can be drilled down. Any ideas?

回答1:

  1. In Details section's 'Section Expert', select 'Format with Multiple Columns'
  2. Select the (now visible) Layout tab
  3. Select 'Format Groups with multiple column'
  4. Add a second group on your date field by year (make sure it is 'outside' the mm/yyyy grouping)
  5. Size the footer of the section you created in #4 to get each year to be in its own column


回答2:

If you group by month name (like monthname({transaction.date}) so January 2011 and 2012 will be in the same group) then you can use a running total to summarize the years individually within that group. You can do this by creating two running total fields, one with an evaluate formula like year({transaction.date})=2010 and another with the formula year({transaction.date})=2011.

Note that running totals won't work in the group header though, so you'd need to migrate those fields down into the group footer instead.



回答3:

How about using a cross-tab like:

           2011    2012
January      10      12
February      5      12
March         8       1

This would be a lot more flexible.