Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Font color by two variables Post Reply Post New Topic
Author Message
lawrenceks
Newbie
Newbie


Joined: 07 Aug 2014
Online Status: Offline
Posts: 6
Quote lawrenceks Replybullet Topic: Font color by two variables
    Posted: 15 Jul 2019 at 10:22am
I am trying to do a complex (at least to me) formula. I need to change font colors of varying items on various dates (months). I am close on the formula by name, but not quite there. As the formula is set up now, it will only change the color of the last variable, not when any of the conditions are met. I am not sure how to add the IF MONTH portion of the formula.

What I am needing is:
In November, December, January and February,
     Name 1 should have an amount less than 5
     Name 2 should have an amount less than 10
     Name 3 should have an amount less than 15
     Name 4 should have an amount less than 20

In March, April, May and June
     Name 1 should have an amount less than 10
     Name 2 should have an amount less than 20
     Name 3 should have an amount less than 25
     Name 4 should have an amount less than 30

In July, August, September or October     
Name 1 should have an amount less than 20
     Name 2 should have an amount less than 25
     Name 3 should have an amount less than 30
     Name 4 should have an amount less than 35

The Amount needs to be red when the amount is greater than the above criteria.

The table looks something like this:
Name          Amount
Name 1          10     //(In January and June, amount would be black, in July, amount would be red)
Name 2          20     //(In January, amount would be red, June and July amount would be black)
Name 3          5     //(all months, amounts would be black)
Name 4          40     //(all months, amounts would be red)


I think that is should be something kind of like this, but I know that it is not correct.

IF month = November OR December OR January OR February THEN
     IF {Name} ="Name 1" AND {Amount} >5 THEN crRed ELSE;
     IF {Name} ="Name 2" AND {Amount} >10 THEN crRed ELSE;
     IF {Name} ="Name 3" AND {Amount} >15 THEN crRed ELSE;
     IF {Name} ="Name 4" AND {Amount} >20 THEN crRed ELSE;

IF month = March OR April OR May OR June THEN
     IF {Name} ="Name 1" AND {Amount} >10 THEN crRed ELSE;
     IF {Name} ="Name 2" AND {Amount} >20 THEN crRed ELSE;
     IF {Name} ="Name 3" AND {Amount} >25 THEN crRed ELSE;
     IF {Name} ="Name 4" AND {Amount} >30 THEN crRed ELSE;

IF month = July OR August OR September OR October THEN
     IF {Name} ="Name 1" AND {Amount} >20 THEN crRed ELSE;
     IF {Name} ="Name 2" AND {Amount} >25 THEN crRed ELSE;
     IF {Name} ="Name 3" AND {Amount} >30 THEN crRed ELSE;
     IF {Name} ="Name 4" AND {Amount} >35 THEN crRed ELSE

IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 15 Jul 2019 at 11:17am
First off you will get a syntax error.  I will assume that month is set somewhere else in the code.
So the first statement which will be similar to other month comparison statement would look something like this.
IF month in ['November', 'December', 'January', 'February'] then ...

Not sure what the {Name} field is, but the first statement that is true, then it fall out (and no semicolons except at the end of the main if statement.  But I will need more time to look at your logic (because your if statements  are redundant, everything is crRed).

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.031 seconds.