I don't want to show null values if my parameter is not empty.

I'm working on a report, and I have several parameters that are Multi-Select type parameters that are set up as $X{IN,column_name,parameter_name}, but in my testing when I select a value for the parameter, I'm also getting rows where column_name is null.  Is there a way to exclude those values IF the parameter is not empty?  

jburczyk's picture
304
Joined: Sep 20 2019 - 1:13pm
Last seen: 2 years 11 months ago

4 Answers:

IF I am understanding you,

If you don't have any values selected then the query returns as if null.  I was able to recreate this.

To make the element (let's say a table) not visible if the parameter is null or not set,

Set the table's advanced propertey of print when visible to only display if the parameter has value.

I was able to evaluate the expression correctly by checking if empty:

$P{Parameter1}.isEmpty().toString()=="false"

 

This effectively only displays the table element if the parameter is not empty.

danoldenkamp@gmail.com's picture
Joined: Aug 29 2018 - 11:12am
Last seen: 2 years 1 month ago

Why not just:

!$P{Parameter1}.isEmpty()

the PrintWhenExpression just needs a boolean value, as isEmpty() already returns true/false there is actually no need to convert it to a String and compare the 'false' string value.

Just my two cents.

regards C-Box

C-Box's picture
20515
Joined: Jul 19 2006 - 5:58pm
Last seen: 5 months 1 week ago

Thanks that's much cleaner.

danoldenkamp@gmail.com's picture
Joined: Aug 29 2018 - 11:12am
Last seen: 2 years 1 month ago

Thank you both for your suggestions.  The issue that I'm having is that when I select values for the parameter, I'm getting those values in the report + the null values, and I only want those values, not the nulls.  Perhaps I just don't have my parameter set up properly.

jburczyk's picture
304
Joined: Sep 20 2019 - 1:13pm
Last seen: 2 years 11 months ago
Feedback