I'm trying to fill subdataset with data. I want to take data from my variable/property, fill dataset and retrieve data from dataset, using $F{field_name}. It is possible?
Yes you can fill the subdataset from main dataset. These are some steps to fill the sub dataset:-
Suppose we have field field_name in main data set and now we want to pass to the sub data set-
Create a parameter $P{p_field_name} and add the default value $F{field_name} in main dataset.
Then edit the query of sub dataset and create parameter $P{pm_field_name} and add the default value $P{p_field_name}
From my experience is not possible to fill a subdataset without using a chart or a list component. If that's your case you can see how to use a list in this video. If you need it for a chart is like this
Otherwise use a subreport and passing your $F{field_name} as datasource, it is explained here
Related
There's a working report but I wan't to change the visibility of certain rows based on a completely new DB select that should be executed when the report is created.
It would be ideal, if I could load the values of said select in an array or a list and than simply trigger certain row's visibility by comparing e.g. the Row Id with the values in the array.
Im used to solve a problem like this by creating a View that delivers all the essential information in each row and is used as the main data source but I was wondering if there's an elegant way within crystal reports to solve such a task.
I can think of three ways to include control data like this into the report:
One row of config data: If you can arrange it that your config data query returns one row of data, it can be just added to the data sources of the main report, without any links to tables and views already there.
Config resultset for matching: If you have to match main data results to config values row by row, e.g. by the Row Id you mentioned, add this config query to your report and link it to the main data source accordingly. (You are probably already doing this within your pre-created view on database side.)
Query config by subreport: Most flexible but also time consuming option is to add a subreport in report header, add the config data query and arrange config results into (shared) variables as needed in the subreport. Shared variable values can be used in main report then to control section visibility.
Yes, one of the 3rd-party Crystal Reports UFLs (User Function Libraries) listed here provides such a function.
I am working in iReport 5.6.0. I am creating a report base utilizing a table and would like to build one or more options to hide a series of columns; effectively creating a master report which will allow users to have multiple report views based on a simple parameter selection. In theory, this should work. However, I am having a problem passing a parameter from the main report it the table (where I am would use it to activate the Column Print When property.
To be clear. I have created an outer parameter and an inner parameter. I have also successfully mapped the parameters. I know that the mapping is working as I have added a column to my table and placed the parameter within the data row so that I can visually evaluate it--this too, works. However, when I set the Column Print When property as
$P{parameter1_1}.equals("y")
or even
$P{parameter1_1}.equals('y')
and then preview the report, I receive the following error:
Parameter not found: Description: parameter1_1 Object: fx $P{parameter1_1}.equals("y")
I have a problem with a report, I pass a array of values to report (from Java code) and that information is loaded inside the report (that works fine). But, I need to pass that field values to a table component, I saw and I can pass parameters to table, but I need use the main field values inside of table component and print that data there (in table component).
I suppose you pass the data from java as datasource. You have to pass the datasource for the table in a parameter and run the report with a different datasource (may be empty if you don't need any data). Then set the table datasource to be that parameter and declare the fields in the subdataset of the table.
See
How to show JRBeanCollectionDataSource data with help of Table component?
or
Two DataSource in report
for examples.
I have a simple SSRS report that displays data from one table. What I want to do is have a distinct list from that table displayed in a drop down list for the user to select. If I only use one dataset I can get it to display, but it displays values from the column multiple times.
Example
Bob
Bob
Bob
Cathy
Cathy
If I create a second dataset that will list distinct values I get the following error message:
An Error occurred during local report processing. The definition of the report is invalid. The Variable expression for the report 'body' refers directly to the field without specifying a dataset aggregate. When the report contains multiple datasets, field references outside of a data region must be contained within aggregate functions which specify a dataset scope.
I"m trying to follow the example I found here:
http://msdn.microsoft.com/en-us/library/aa337400.aspx
The second dataset is only for the parameter list. I don't understand why it's causing problems with the actual report.
It's impossible to tell exactly where without the report definition, but there is an item on the report that is referencing a field or Dataset, and was implicitly using the only Dataset present in the report, but now doesn't know which Dataset to use once more than one is added to the report.
For example, when you create a table you can set a Dataset associated with it. If this is not set and there is only one Dataset, it doesn't matter as it will take the only one available. Once you add a new Dataset, the table doesn't know which one to use and you'll get the error you're seeing.
Another way to get the error is specifying a field in an expression, e.g. in a TextBox in the report somewhere without specifying the scope; just set the scope to a particular Dataset e.g. if you have:
=Count(Fields!name.Value)
change this to:
=Count(Fields!name.Value, "DatasetToUse")
If you've only got one Dataset the first expression will run fine by using the only one available, but once you add another it won't know which to use and it will error.
in the query (SQL) you should add DISTINCT clause at the beginning, that way, you will get only one record per value. Check out http://www.w3schools.com/sql/sql_distinct.asp
Double click the Dataset which contains that field.
Go to fields on the left and delete that field.
Add new field by clicking Add -> Query Field.
Just type in the name of the new field under field name and field source.
It happens when you have added a field by selecting "Calculated Field" instead of "Query Field" from Dataset Fields list tab.
Cheers,
Ahmed Latif
I am new to JasperReports. I need to design a report where certain columns and rows are dynamic. For this how I have to design the report and after design i want to integrate with my application for fetching data from action class and dto. How to map data for its?
I don't know how dynamic it will be, but it may help you: http://dynamicjasper.com/
It uses JasperReports to generate your report and it also allow you to create your report on the fly.
There are 2 options to map data with the columns. First option is u can pass ur data into data Source binding with the column name as key value pair. And the second option is u can pass the obj of your dto to data source directly in list form.
Use report.setDataSource() for setting the data. In first option make sure your type of the data matches with the column name.