Input Parameter from list derived from query?

Building a report in jaspersoft studio 6.0.1 and pushing to jasperreports server 5.5.0.

The portion of query I am trying to get to work is 

"select state_name, count(1) from sales.by_state where ($P{chosen_states}='ALL' or state_name in ( $P{chosen_states} group by state_name))"

I would like to have an input parameter with a list of existing state_names that exist on the by_state table. Also, I would like to add to the checkbox list an "ALL" option which should return everything.

Is this possible?

 

 

----edit-----

I've changed my where clause to where $X{IN,state_name,chosen_states} and se the chosen_states parameter to java.util.List, which seems to help me get a little bit of the way there. Is there a way to dynamically populate the chosen_states with all that show in the query if running everything?

d.b's picture
d.b
138
Joined: Dec 30 2014 - 6:59am
Last seen: 8 years 2 weeks ago

1 Answer:

I was searching for an answer to do it all in Jaspersoft Studio, but I don't know if its possible. 

This is what I did:

  1. Sent report with parameter to jasperreports server
  2. Added a Query resource that got the distinct list of states from this table
  3. Edited the report's input control to read from the Query created, setting as type Mulit-Select Query

Would there have been a way to do this all in studio? It would be REALLY great to know, because it seems like everytime I update the report in studio and push it to the server, I have to reconfigure the input control. Very annoying!

d.b's picture
d.b
138
Joined: Dec 30 2014 - 6:59am
Last seen: 8 years 2 weeks ago
Feedback