Jump to content
JasperReports Library 7.0 is now available ×

Calculating Percentage for a column in a List Component Dataset


pandit.sumit

Recommended Posts

I have the following query for a dataset:

select item, sum(salesAmount) as TotalSales from sales group by item order by TotalSales desc;

and I have set REPORT_COUNT<=5 for limiting the data to 5 records only. Now I want to display top 5 items through a list component and their Sales Amount in percentage to that of the TotalSales amount of the top 5 items. I have created a variable in the dataset as sales_sum

class: BigDecimal

Calculation : Sum

Reset Type : Report

Increment Type : None

Variable Expression : $F{TotalSales}

Now I am adding a text field and using expression $F{TotalSales}/$V(sales_sum) and set the evaluation time to Auto. But it is returning null and a NullPointerException What should I do? Thank you

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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