Default value for a parameter left blank

Hi all, hope you can help me. I have several filters (parameters) in my report like gender, eye color, hair, etc. The user can select each characteristic or left it blank. When left blank, the report should return all records. For each filter I started to use something like: SELECT * FROM CANDIDATES where $P{GEND} = GENDER but this way the parameter can't be left blank. How can I change the script in order to allow blank filters to return all options? Thanks in advance
lmbaptista's picture
Joined: Jul 31 2014 - 3:52am
Last seen: 2 years 9 months ago

1 Answer:

Read page 105 in "Jaspersoft Studio  Users Guide" about using $P!

hozawa's picture
Joined: Apr 24 2010 - 4:31pm
Last seen: 4 years 3 months ago

Thanks for your reply Hozawa. I not only checked the manual like I also search the web for some hints. Right now I created a second parameter to include a "If clause" and I have this:

To select the GENDERID (since it's a test, I'm using 1 and 2) and with Prompting

with the default expression: $P{GENDER} == null ? "GENDERID>O":"GENDERID = " + $P{GENDER}
and without prompting

In the Query Editor I use:
where $P!{ALLGENDER}

This works fine when I select a gender (1 or 2), but once again, if I left the parameter null I get the message "The report requires that you specify the value for some parameters before running it."

Any suggestions?
Thanks in advance

lmbaptista - 9 years 1 month ago