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

Can you sort using a variable?


cherieh

Recommended Posts

In this instance, I have to use a csv file as my source.  Can I sort the report based on a variable instead of a field?  I am using iReport v.3.7.4.  Please help.  Everything i have read in the forums and books is leaning to no but thought there may be a way i am overlooking.

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I often use a an Ireport variable in my SQL statements.  This gives my users the ability to sort on different fields of the report.  In this case, create a "Parameter" instead of a variable.  Here's a shor example:

I have a parameter called "user_choice" which I default to "city".  The user may change this by selecting from a list, say "City", "State" or "Zip"...The SQL qould look something like this:

select

  name,

  address.

  city,

  zip

from

  phone_book

order by

  $P!{user_choice}

 

Make sure to include the "!" point.

 

David

 

Link to comment
Share on other sites

  • 4 months later...

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