Jump to content
We've recently updated our Privacy Statement, available here ×

How to get an average instead of a total for a pivot table in a report


Recommended Posts

Hi Folks:

I have a pivot table that by default it seems is giving a total value for each animal grouping (The darker blue).   What I want though is an average of those three years for each animail.

Here is an example of how it looks:

pivot_report_totals.png.ace9eeac0e8959ba1052b785d3f8f2e9.png

Code view:

pivot_report_code.png.a9d1b4761a7a4c3a15e1ddc0d02e8cba.png

Expression Editor:

I figured would be able to find an "avg" function or something but didn't.  This is probably simple to change but I can't figure it out...

Thanks for any help....

current_expression.png.4b225e84eafb837235ff961022731582.png

 

Thanks,

Matthew

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Posted Images

Hi Folks:

I guess if I can figure out how to divide the variable by 3 I could get the result I want.

 

So I've tried stuff like:  $V{CORN1_MEASURE}.divide( java.math.BigDecimal ,3 )     which gives an error because I'm dong something wrong.   What do I need to put after   $V{CORN1_MEASURE}   to divide by 3? 

Thanks :)

Link to comment
Share on other sites

You have at least two options: 

  1. create a new measure, based on the same field that corn1_measure uses, but set the measure calc to AVG rather than SUM, and drop that into your row totals as needed
  2. if you want to do the divide method, you'll need to do someting like $V{CORN1_MEASURE}.divide(new BigDecimal(3))

Check google / stack overflow on how to divide BigDecimal if what I provided throws an error

 

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