How to set a variable value equal to a field value where id is equal to a certain value?

0

Hello all.

Before I state my issue I just want to provide some information on my specs.

I'm using a mysql database as my datasouce and jaspersoft studio community edition v6.3.1.

The report I'm creating should have a title page that displays very specific information from the first few rows in my database. For example:

id sectionid sectiontext entrytext isnewpage
1 1 null null 0
2 1 Example Company Example Text 0
3 1 Financial Report Q1 0

Knowing this (and also knowing that the data can change based on user inputs), I wanted to be able to store the value of a specific field into a variable where the id was equal to a certain value.

I created a variable and set the Inital Value Expression to this: $F{id}.equals(3) ? $F{sectiontext} : "Nothing"

I then placed that variable onto the Title section of the report designer to see what would display when Previewing the report and I only got null

So with that being said, is it possible to store the value of a field into a variable WHERE the primary key for that row is equal to a certain value? and if so, does that mean the value of the variable does not change so long as the value in the datasource is the same even when the report is in run time?

If anyone knows how to implement or even if this is possible, please let me know! thanks

 

daniel.la's picture
Joined: Jan 19 2017 - 11:36am
Last seen: 2 years 5 months ago

0 Answers:

No answers yet
Feedback