Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Highlighting a group in section expert Post Reply Post New Topic
Author Message
Robotacha
Groupie
Groupie
Avatar

Joined: 11 Nov 2009
Location: United Kingdom
Online Status: Offline
Posts: 97
Quote Robotacha Replybullet Topic: Highlighting a group in section expert
     Posted: 22 Sep 2011 at 1:02am
Hello,
 
Hope somebody can help.
 
I have 2 groups:
 
Group1 - Customer
Group2 - invoice number
 
both groups have a Summarized total quantity field
(group1 total = total units purchased in September)
(group2 total = total units purchased on a single invoice)
 
 
I have supressed group2 using this formula:
 
IF Sum ({TABLE1.QUANTITY}, {TABLE.INVNUM})<4 THEN TRUE
 
which will then only shows invoices with a total of more than 4 units.
 
 
What I want to do, is highlight the group1,  based on whether group2 has any data.
 
 
for example: (my report currently looks like this)
 
CUSTOMER A   -  units:38
inv123456 - units:8
inv125457 - units:7
inv125487 - units:4
CUSTOMER B  -  units:24
inv124587 - units:5
inv154774 - units:4
CUSTOMER C  - units:9
CUSTOMER D  - units:12
inv154588 - units:6
inv155887 - units:4
 
As you can see, CUSTOMER C has purchased 9 units this month, but has not had more than 4 on a single invoice.
 
I want to highlight this (and all other customers who fall into this criteria) in red.
 
so it will look like this:
 
CUSTOMER A   -  units:38
inv123456 - units:8
inv125457 - units:7
inv125487 - units:4
CUSTOMER B  -  units:24
inv124587 - units:5
inv154774 - units:4
CUSTOMER C  - units:9
CUSTOMER D  - units:12
inv154588 - units:6
inv155887 - units:4
 
 
Any Ideas?
 
Ive tried adding this into the section expert(colour) for group 1:
 
IF Sum ({TABLE1.QUANTITY}, {TABLE1.INVNUM}) THEN crred
 
 
but it does not work :(
 
 
Thanks in Advance :)
 
Regards,

Michael Jones
IP IP Logged
Robotacha
Groupie
Groupie
Avatar

Joined: 11 Nov 2009
Location: United Kingdom
Online Status: Offline
Posts: 97
Quote Robotacha Replybullet Posted: 22 Sep 2011 at 3:16am
How can I count the rows returned in GroupHeader2, and show this count as a number on GroupHeader1?
 
I could then colour GroupHeader1 based on the count of GroupHeader2 rows?
 
ie; If COUNT = 0 THEN crred
 
 
please help :\
Regards,

Michael Jones
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 22 Sep 2011 at 3:22am
well, the thought that comes to mind, is to put the values that you want to display in the group footer...well that would work for the red, but then you would have dupes....
 
ok, back my very first thought....
make a subreport that will set a shared variable with a flag or a count of orders that have the minumum value.  place the subreport before the group header (i would make another g1 section(for example) and move on top of existing group header (g1 in this case)).  make the subreport 'invisible' (this can be tricky so more later), then you can change the color of the font in the group header (since you know that there won't be any details displayed.
 
This is not optimal as all of your data is going to be read 2 times, with many many hits to the database.  If there aren' t many rows in the report, it probably won't be noticed, but that is the caveat.
 
How to hide a subreport and still get it to run?  Suppress all the output on the subreport(after all we are after the shared variables value), then in the section, go to section expert and select 'suppress blank section'
 
HTH
 
ps my favorite solution is to create a stored procedure, then if you wanted you could include a flag in the records that would tell you whether the group had any entries that met your requirements...this reduces your hits to the database to just 1, gets rid of the need of the shared variable and the subreport...but not everyone is able to implement this style of solution.


Edited by lockwelle - 22 Sep 2011 at 3:24am
IP IP Logged
Robotacha
Groupie
Groupie
Avatar

Joined: 11 Nov 2009
Location: United Kingdom
Online Status: Offline
Posts: 97
Quote Robotacha Replybullet Posted: 22 Sep 2011 at 3:56am
Whilst I understand what you have said, and forgive me for my ignorance,
 
But how do I count the qualifying rows in the sub report?
 
 
Regards,

Michael Jones
IP IP Logged
Robotacha
Groupie
Groupie
Avatar

Joined: 11 Nov 2009
Location: United Kingdom
Online Status: Offline
Posts: 97
Quote Robotacha Replybullet Posted: 22 Sep 2011 at 4:30am
I ended up doing it a different way.
 
Dont know how it worked, but it did...
 
I created a formula called
@linecheck
IF {TABLE1.QTY}>=4 THEN 1 ELSE 0
 
Then summarized this formula by CUSTOMER group.
 
in section expert(colour) I put:
 
IF Sum ({@LineCheck}, {TRNSTK.CUSTOMER})=0 THEN crred ELSE crsilver

And it worked..... :\ dont know how, but it did.
Regards,

Michael Jones
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 22 Sep 2011 at 4:42am
I think this appears to be 'working' by happenstance of the curretn data.
Right now every inventory that has all rows <4 also happen to have a sum of the rows < 4.
If you get an inventory with all individual rows qty<4 but the sum of the qty>=4 your formula will not be doing what you want.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 22 Sep 2011 at 5:02am
as for the counting in the subreport, you would basically do the same criteria as in the main report for suppression, just increment a counter when the qty works....so if no rows in the data have the value > 4, you would return 0, otherwise the number of rows that met your criteria.
 
Since it would be a shared variable, you will need to reset it (probably before you call the subreport or in the header of the subreport)  Then it would probably be incremented in the detail section of the report (depends on the report layout/values in the data)
 
I respond just for future reference, since you found another way that appears to work (taking DBlank's comments into account).
IP IP Logged
Robotacha
Groupie
Groupie
Avatar

Joined: 11 Nov 2009
Location: United Kingdom
Online Status: Offline
Posts: 97
Quote Robotacha Replybullet Posted: 22 Sep 2011 at 11:23pm

THanks for the replies.

 
Yes DBlank, I see what you mean.
 
Its is for a promotion we are running. If the customer purchases 4 or more units of a specified brand on 1 single invoice, he qualifies for a scratchcard to win a prize.
 
 
I had 1 customer who was flagged as RED, but had a sum of >=4. When I looked into it, it was because he had 3 lines on the invoice. x2 brand, x2 brand, & x1 brand.
 
so he had actually 4 units on 1 invoice, but the individual line qtys were 2, 2 & 1
 
so, thanks for that input :)
 
The only reason I wanted to identify these, was to see customers who had purchased 30 , 40 units during the month, but had not qualified for any scratchcards.
 
we can then see who is buying the specified brand, but not in multiples of 4 (missing out on the scratchcards)
 
 
I will consider lockwelles suggestion and get my head around it later on this afternoon.
 
Again, thanks for your help. I find this forum extremely useful (even with the timezone constraints, I always seem to get a reply on the same day)
 
Thanks Guys.
Regards,

Michael Jones
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