Jasper Report - Sort Report Content By Report Variable
In here I’m using
Product Version: Jaspersoft iReport Designer Professional 5.0.0
Java : 1.6.0_45
System : Windows 7
First create jasper report variable, in this example it is Expenditure_order.
According to my requirement it is type of String and calculation nothing and Reset type Report.
After that we need to define variable expression for sorting.
In my case there are 3 expenditure types. Let’s say Recurrent, Public Debt and Capital.
So I need to sort this as Recurrent, Capital and Public Debt.
When I use Ascending order it return Capital, Public Debt and Recurrent.
When I use Descending order it return Recurrent, Public Debt and Capital.
So I’m not able to use Ascending or Descending order for these criteria.
So I have used variable expression for change the sort order.
Now click on ok button and then we have a sorted variable.
Then move to the jasper report query window using this icon.
In Query window there is a button called Sort options.
Click on Sort options button and then you can get Sorting window.
In here we can add sort field in to the report.
Click on Add field button the and then you can get Add/Modify parameter window.
In Add/Modify parameter window, you can select sort by variable,
According to the example it is Expenditure_order and you can define sort type also.
Then click on ok button
So now we add the sorting variable successfully.
If you need you can remove or modify the sorting variable.
Also you can add more than one variable if you required.
Click on close button to exit.
Click on button to exit from query window.
After this report content ordered according to requirement (Recurrent, Capital and Public Debt).
Thank you
ReplyDelete