Print Page | Close Window

Font color by two variables

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22797
Printed Date: 27 Apr 2024 at 8:02pm


Topic: Font color by two variables
Posted By: lawrenceks
Subject: Font color by two variables
Date 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




Replies:
Posted By: kevlray
Date 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).




Print Page | Close Window