Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Conditional formatting Post Reply Post New Topic
Author Message
db3712
Groupie
Groupie
Avatar

Joined: 30 Oct 2008
Location: United States
Online Status: Offline
Posts: 44
Quote db3712 Replybullet Topic: Conditional formatting
    Posted: 15 Jan 2013 at 6:18am
Hello,
I'm new to conditional formatting and would appreciate any help.  I have a two fields.  One is a number field and the other is a formula which is essentially a summary of two other number fields.  I would like to highlight one or both of the fields if they don't match.  Can you do conditional formatting on a summary field?
 
Thanks!
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 15 Jan 2013 at 6:34am
well, if you add a section to the group footer, and set your summarized value to a shared (or global) variable, then when you actually display the values, you can tap into your shared variables and use them to change the background color.
 
another way of saying the same thing.  find the values that you want to compare. store them in shared variables in a section above the displayed value, then access the variables to change the color.
 
example
gf1a:
shared numbervar col1 := {table.field1};
shared numbervar col2 := {table.field2};
""  //will suppress any display of the values (though you can also suppress the section
 
gf1b, {table.field1}, format object, font (i think) color, check the background(ithink)
shared numbervar col1;
shared numbervar col2;
if col1 <> col2 then
  crRed
else
  crWhite;
 
HTH
IP IP Logged
db3712
Groupie
Groupie
Avatar

Joined: 30 Oct 2008
Location: United States
Online Status: Offline
Posts: 44
Quote db3712 Replybullet Posted: 15 Jan 2013 at 7:28am
I don't completely understand.  I apologize.  It appears you want me to create two additional group footers.  Are you indicating I need to create a formula with the first gf1a above and then place a conditional format on the first formula?   I appreciate your help.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 15 Jan 2013 at 8:16am
before you move to far, you should clarify if your "summary of two fields" is adding across rows or just adding two fields on the same row. Lockwelles suggestion is a way to handle adding multiple values across rows together
IP IP Logged
db3712
Groupie
Groupie
Avatar

Joined: 30 Oct 2008
Location: United States
Online Status: Offline
Posts: 44
Quote db3712 Replybullet Posted: 15 Jan 2013 at 8:29am
Both fields are located in the same group footer.  One is a field straight from database.  The other is a summary of the following formula....
 
if isNull ({orders.is_vendor_flat_rate}) then {demand.total_cost}
else if {orders.is_vendor_flat_rate}= 'Y' and {demand.bpart_gcl_id}= 'Labor'
then {orders.vendor_flat_rate}
else
{demand.total_cost}  
 
I need to highlight the fields if they don't match.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 15 Jan 2013 at 9:33am
if you right click on your group footer, you will see an option about adding another section. It will add a section, with a letter below your current section. Click on it and drag it above the section.
 
Now you have a 'row' to get the value of the formula so that in the next 'row' your true group footer you can compare the values.
 
 
 
as I think about it, you can probably just augment your formula for use in the color selection...
 
local numbervar x;
if isNull ({orders.is_vendor_flat_rate}) then x:={demand.total_cost}
else if {orders.is_vendor_flat_rate}= 'Y' and {demand.bpart_gcl_id}= 'Labor'
then x:={orders.vendor_flat_rate}
else
x:={demand.total_cost}  
 
if x <> {table.otherField} then
  crRed
Else
  crWhite
 
you would use the same formula in both color decisions, I don't think it is as clean as the other solution, but it is more straight-forward that does not require another group footer.
 
hope one of these works for you.
IP IP Logged
db3712
Groupie
Groupie
Avatar

Joined: 30 Oct 2008
Location: United States
Online Status: Offline
Posts: 44
Quote db3712 Replybullet Posted: 15 Jan 2013 at 10:01am
One last question and I'll leave you be.  Thank you very much for your help this afternoon.  Where you say "if x <> {table.otherField} then" color portion of the formula, where do I put that?  I was able to use your first section of the fomula without error.  I just don't know where to apply the color setting portion of the formula.  I'm obviously a newby at this.  Thanks again for everything!
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 15 Jan 2013 at 10:58am
if you right click on the object that you want to change the background of, you can click on the 'format field', then the 'border' tab. Check the 'background' box, and finally the x-2 to the far right of the 'background' checkbox.
 
you can either copy the code from the formula into each object or call the formula...i've seen it done in other code, but don't do it myself, so you might need research how to do that...i think you just use @formulaName, but I could be wrong.
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.063 seconds.