Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Color Group Items Post Reply Post New Topic
Author Message
Stang67
Newbie
Newbie
Avatar

Joined: 14 Apr 2011
Online Status: Offline
Posts: 12
Quote Stang67 Replybullet Topic: Color Group Items
     Posted: 07 Nov 2013 at 11:33pm
Hi Guys,

i have a little Problem.
In  my report i have a group {items.row}

Now i need to color every second item of every single group, like this:
Group 1
item 1 - crGrey
item 2 - crNoColor
item 3 - crGrey

Group 2
item 1 - crGrey
item 2 - crNoColor

Group 3
item 1 - crGrey
item 2 - crNoColor
item 3 - crGrey
item 4 - crNoColor

So every group must start new with coloring the items.

Can anybody help me?

many thanks
Mike Smile
IP IP Logged
manjucrystal
Newbie
Newbie


Joined: 11 Feb 2013
Location: India
Online Status: Offline
Posts: 13
Quote manjucrystal Replybullet Posted: 08 Nov 2013 at 1:22am
Hi
 
In Group Header, drag groupnumber from special field and suppress it.
 
Then go to Group section expert, color tab then enable background color and click 'X-2' button and put this formula
 
if (groupnumber mod 2)<> 0  then
crGray
else
crnocolor
 
HTH
IP IP Logged
Stang67
Newbie
Newbie
Avatar

Joined: 14 Apr 2011
Online Status: Offline
Posts: 12
Quote Stang67 Replybullet Posted: 08 Nov 2013 at 1:42am
Hi manjucrystal,

thanks for the tip.
I already tested this and doesn't work at all - don't know why.


I solved it now with the database:
ROW_NUMBER() OVER (PARTITION BY "row_name" ORDER BY "row_name" ASC) AS GroupRank
So you get for each item of  group a new rank like:

Group 1
item 1 - rank (1)
item 2 - rank (2)
item 3 - rank (3)

Group 2
item 1 - rank (1)
item 2 - rank (2)

Now I can work with the same if-condition like yours :)
if (Remainder ({items.GroupRank}, 2) = 0)
then
crNoColor
else
Color (212,212,212)

But many thanks for your help :D


Edited by Stang67 - 08 Nov 2013 at 4:59am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 08 Nov 2013 at 4:37am
FYI - a crystal solution would have been to use shared variables or a Running Total to set the a counter that resets on each group
RT version is:
name=BGcolor
type = count
field to evaluate=any field that is on every row (no nulls) e.g. item field
evaluate= for each record
reset=on change of group (select group level 1)
this would give you the same result as your Rank allowing your to use it in the color formula
 
if ({#BGcolor} Mod 2 = 0)
then
crNoColor
else
Color (212,212,212)
 
IP IP Logged
Stang67
Newbie
Newbie
Avatar

Joined: 14 Apr 2011
Online Status: Offline
Posts: 12
Quote Stang67 Replybullet Posted: 08 Nov 2013 at 4:52am
Hi DBlank,

I've tried your version and it works exactly like my db-version :D

Many thanks for this tip - for the next time i have two solutions :)
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum