Help Creating Conditional Expression
Posted on November 12, 2015 at 9:19am
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.
Joined: Jan 27 2014 - 7:59am
Last seen: 4 years 10 months ago
Posted on November 13, 2015 at 1:37am
If the fields are BigDecimal you can also cast them to Integer or Float first with BigDecimal.intValue() and BigDecimal.floatValue()
Joined: May 21 2013 - 10:18am
Last seen: 4 years 12 months ago
Posted on November 12, 2015 at 9:29am
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}
Joined: May 21 2013 - 10:18am
Last seen: 4 years 12 months ago
Posted on November 12, 2015 at 10:23am
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})
Joined: Jan 27 2014 - 7:59am
Last seen: 4 years 10 months ago
Casting as float allowed me to use the * and > expressions.