Jump to content
Changes to the Jaspersoft community edition download ×

to all the expert can u help me about date average


Recommended Posts

hi!! my problem is, i want to get the average transaction = TOTAl / no of days from Starting Date to End Date


variable name<name>

variable class type<java.lang.long>

reset type<none>

calculation type<average>

increment type<none>


variable expression


new Long(($F{total}.longValue() / new Long(($P{toDt}.getTime() - $P{fromDt}.getTime())/1000/60/60/24).longValue()))


thanks in advance



Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

You probably don't want to set the variable's Calculation Type to "average". Set it to "Nothing" instead, otherwise all your caluclations will be averaged over "the number of records processed so far".



And I reckon that the result should be a Double:



new java.lang.Double( $F{total}.doubleValue() / ( ( $P{toDt}.getTime()-$P{fromDt}.getTime() ) /864000000 ) )



Use the Text Field's format string to truncate the fractional part to the number of digits you want to display.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...