Return variable from subdataset in main dataset
Posted on July 2, 2022 at 10:34am
Hi Community,
hope someone can help me.
I am trying to return a value from a subdataset into the main dataset as mentioned at jaspersoft studio - How to add variable from subdataset to report? [Jasper] - Stack Overflow
I have created a variable (SUB_Varaible) in the subdataset and set the Expression to the relevant Databasefield:

I have then created another variable in the main dataset (Main_Variable):

In a list (or table) I created the return value mapping:

I then drag and drop the Main_Variable onto the report but it is still evaluated as “null”.
How can I fix this?
Thank you!
Joined: Aug 25 2021 - 12:15am
Last seen: 7 months 1 week ago
Posted on July 2, 2022 at 6:44pm
Perhaps the last step seems to be missing.
>I then drag and drop the Main_Variable onto the report but it is still evaluated as “null”.
After this, try setting 'EvaluationTime' to 'Report'.

Joined: Aug 17 2018 - 3:48pm
Last seen: 3 months 2 weeks ago
Posted on July 3, 2022 at 2:59am
Thanks! I already set it to "Report":

Do you have a change to upload a sample .jrxml where it works, please?
Joined: Aug 25 2021 - 12:15am
Last seen: 7 months 1 week ago
Posted on July 3, 2022 at 7:02am
Unfortunately I have no other notices.
If you could attach the *.jrxml file, I might have some additional insights.
Joined: Aug 17 2018 - 3:48pm
Last seen: 3 months 2 weeks ago
Posted on July 3, 2022 at 9:55am
Attached the .jrxml. I have just used the sample DB for testing with the following SQL statement to have only one value:
select * from Address where Firstname = 'Laura' and Lastname = 'Miller'
Joined: Aug 25 2021 - 12:15am
Last seen: 7 months 1 week ago
Posted on July 3, 2022 at 11:30am
just found the issue:
The calculation in the subvariable must not be set to "system" but to what is needed based on the data.
All the other settings above were fine.
Thanks anyway!
Joined: Aug 25 2021 - 12:15am
Last seen: 7 months 1 week ago