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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alternate colours when Grouping by mulitple fields...

Status
Not open for further replies.

sogc

Technical User
Jun 8, 2004
34
CA
FACTS:
1. Using Crystal 9
2. Using 2 fields to group by.
3. Using the following formula to alternate background colour of Group section:
if Remainder(GroupNumber, 2) = 0 then Color (241,189,80)
else Color (237,171,33)

PROBLEM:
The colours are not alternating properly because the group number does not reset itself after each 1st level group. Instead, GroupNumber counts all groups no matter what level of grouping it is. As an example. My first level grouping is, say, Buicks and my second is Accords. My second level grouping is Years, 1999, 2000 and 2001. The result is that Buicks and Accords both get an odd group number assigned and they get the same colour where in fact I want them to alternate (as I hide the detail for a later drill down).

Buick - 1
1999 - 2
2000 - 3
2001 - 4
Accord - 5
1999 - 6
2000 - 7
2001 - 8

I had expected the group number to work like this:

Buick - 1
1999 - 1
2000 - 2
2001 - 3
Accord - 2
1999 - 4
2000 - 5
2001 - 6

Any suggestions for a work around.
 
Did you use a variable to create "GroupNumber"? In 8.0, adding the "Special field"->Group Number results in this count:

Buick - 1
1999 - 1
2000 - 2
2001 - 3
Accord - 4
1999 - 4
2000 - 5
2001 - 6

...which results in alternating colors for the Group 1 fields. A variable placed in both group 1 and group 2 fields would create the consecutive count you are getting. It's unclear whether you are trying to highlight only the group 1 fields, though.

-LB
 
I did not create a variable. I am using GroupNumber function which is included in CR9. I am adding the formula above in Fact#3 to the background color formula of a particular group section.

I am trying to highlight the Group1 fields alternatively in the preview tab. Then I suppress that group header and I hightlight the Group2 fields alternatively in the GH2 section header.

So I have set my Group2 section to Hide (drill-down OK).
This is what I was hoping how groupnumber would work.

PREVIEW TAB
Buick - 1
Accord - 2

BUICK DRILLDOWN
1999 - 1
2000 - 2
2001 - 3

ACCORD DRILLDOWN
1999 - 1
2000 - 2
2001 - 3

Thanks for any assistance.
 
Use a manual counter for this:

In report Header:

//@Intialize
global numbervar groupcount := 0;

In group1 header:

//@GroupColor
global numbervar groupcount;

groupcount := groupcount + 1;

if remainder(groupcount,2) = 0 then color1
else color2;

substitue what colors you want in color1 and color2

The first color will be "color2"

Lisa
 
Oh.. @GroupColor goes into the x=2 for color for the section.

Lisa
 
And then create a second variable like the one lyanch used for Group 1 for Group 2, using a different variable name and placing it only in the Group 2 header.

-LB
 
Thanks Lisa. I tried your formulas. However, the counter is not incrementing. Groupcount variable remains at 1 and so the color does not change.

However, I took your idea and created a Running Total Field to count the groups.

Thanks for your assistance.
 
The formulas should start with "whileprintingrecords;" in order to increment.

-LB

 
You may want to try if recordnumber mod 2=0
then silver else nocolor

(or whatever color scheme you want)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top