Display subreport data in columns, not rows
Quote from lekrof on 11. August 2025, 14:38Hi,
this problem first looked like a crosstab solution to me, but not quite: I would like to display data that is currently in a subreport (1 row per subdata set) to be "transposed" so that each subdata set is in a separate column, see sections highlighted in yellow in the screenshots.
There is no fixed number of subdata sets, but up to now there is a maximum of 6 per data set.
The report will be optimized for Excel output only, so page width is not really an issue.
Thanks for any ideas!
Hi,
this problem first looked like a crosstab solution to me, but not quite: I would like to display data that is currently in a subreport (1 row per subdata set) to be "transposed" so that each subdata set is in a separate column, see sections highlighted in yellow in the screenshots.
There is no fixed number of subdata sets, but up to now there is a maximum of 6 per data set.
The report will be optimized for Excel output only, so page width is not really an issue.
Thanks for any ideas!
Uploaded files:Quote from Gustaf Folger on 11. August 2025, 14:51Hello lekrof,
Could you specify what kind of data source you are using? Also, will your columns always contain a fixed number of rows or can they vary?
Hello lekrof,
Could you specify what kind of data source you are using? Also, will your columns always contain a fixed number of rows or can they vary?
Quote from lekrof on 11. August 2025, 15:05Hi Gustav,
It's an Oracle database, one table for product characteristics, another one for the substance properties. Primary key is a substance code in both tables.
Hi Gustav,
It's an Oracle database, one table for product characteristics, another one for the substance properties. Primary key is a substance code in both tables.
Quote from lekrof on 11. August 2025, 15:06... at the moments, there is a fixed maximum number of rows = substances per product, but there may be more in the future.
... at the moments, there is a fixed maximum number of rows = substances per product, but there may be more in the future.
Quote from Gustaf Folger on 12. August 2025, 8:03Alright, there's a few possible solutions here. You could derived table using a subquery and create a field for each value in each column. You can use print when statements to check for null values to not include columns.
I'm attaching an example of what this could look like. This could be a lot of manual labour but if the final product looks like your example then it should be manageable. If your tables grow then you will need to manually add more rows to your query.
Given you are using oracle it should also be possible to use a pivot query but I don't have a test database currently so I can't really show an example currently.
The best solution would likely still be a crosstab though. How come that doesn't work for you?
Alright, there's a few possible solutions here. You could derived table using a subquery and create a field for each value in each column. You can use print when statements to check for null values to not include columns.
I'm attaching an example of what this could look like. This could be a lot of manual labour but if the final product looks like your example then it should be manageable. If your tables grow then you will need to manually add more rows to your query.
Given you are using oracle it should also be possible to use a pivot query but I don't have a test database currently so I can't really show an example currently.
The best solution would likely still be a crosstab though. How come that doesn't work for you?
Uploaded files:Quote from ThoZi on 12. August 2025, 9:55Hi lekrof.
I moved that issue to "standard Jasperreports Questions"...
Regarding your question: why exactly does a Crosstab not work for you? That would be an interesting question to be answered, before searching for alternate solutions in SQL or report structure, which are propably all not easy nor dynamic...
Thanks in advance,
Thomas
Hi lekrof.
I moved that issue to "standard Jasperreports Questions"...
Regarding your question: why exactly does a Crosstab not work for you? That would be an interesting question to be answered, before searching for alternate solutions in SQL or report structure, which are propably all not easy nor dynamic...
Thanks in advance,
Thomas
Quote from lekrof on 12. August 2025, 11:35@ Gustaf and Thomas: Thanks a lot!
I will try the crosstab option first and report back asap..
@ Gustaf and Thomas: Thanks a lot!
I will try the crosstab option first and report back asap..