Help Creating Conditional Expression

Hello All,

I am not very good when it comes to java and i was hoping someone could help me with some conditional formatting in a report.

I have two columns that both contain BigDecimal values. One columns is the averages sales per day (over the past 60 days), and the second column is the total sales over the past 3 days.

I would like to create a conditional style that highlights the 3 day sales value if it is over 3 times larger than the average day sales. This is to show a recent influx of sales on a product over the past 3 days compared to the typical average.

Here is an exmple of the simple math expressions:

if  (3 day total) > (60 day average x 3) - highlight green

I am pretty sure i can set up the styles how i want, i just dont know how to take the above math expression and actually create a java expression out of it.

 

Any help or advice would be appreciated.

adam_7's picture
261
Joined: Jan 27 2014 - 7:59am
Last seen: 4 years 10 months ago

Casting as float allowed me to use the * and > expressions.

adam_7 - 7 years 10 months ago

3 Answers:

If the fields are BigDecimal you can also cast them to Integer or Float first with BigDecimal.intValue() and BigDecimal.floatValue()

plambert_1's picture
1617
Joined: May 21 2013 - 10:18am
Last seen: 4 years 12 months ago

Indeed you can set a conditionnal style with such an expression.

in your case the conditionnal expression would simply look like : 

$F{3daysTotal}>3*$F{60daysAverage}

plambert_1's picture
1617
Joined: May 21 2013 - 10:18am
Last seen: 4 years 12 months ago

I get undefined operators when i try to use > or * in the expression. That was my problem when trying to get the expression set up.

 

I think it wants me to use java expressions like this from a different report i have:

($V{Margin}.divide($V{Adjusted Retail})

 

adam_7's picture
261
Joined: Jan 27 2014 - 7:59am
Last seen: 4 years 10 months ago
Feedback