How to Show/Hide Table Object Columns - jasper-reports

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")

Related

Use SQL Select directly in CR Function

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.

Jaspersoft Table Element No data displayed

I have a table component on a subreport being used with an independent data source (dataset) thats hooked onto the table object. The table has two columns, the following issues arise upon debugging:
Not all descriptions are loaded from the query I used
The second column is not showing the data at all
Is there any properties that I am missing?
Thank you
Kind reagrds
Zain Nabi
Jasperstudio reports require all parameter names to be the same.

Passing field values to table component

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.

SSRS Multiple Dataset Errors

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

SSRS field scope issue

I have an SSRS 2008 R2 report that uses this expression in a table:
=Lookup(Fields!DataSet1Date.Value, Fields!DataSet2Date.Value, Fields!DataSet2Price.Value, "DataSet2")
I have 2 data sets and am using the Lookup function to get data from one dataset based on the date in another dataset.
My problem is that this works on machines that I have tried it on, but others are getting errors like this:
Error 1 [rsFieldReference] The Value expression for the text box ‘Col_D2Price’ refers to the field ‘DataSet2Date’. Report item expressions can only refer to fields within the current dataset scope or, if inside an aggregate, the specified dataset scope.
Error 2 [rsFieldReference] The Value expression for the text box ‘Col_D2Price’ refers to the field ‘DataSet2Price’. Report item expressions can only refer to fields within the current dataset scope or, if inside an aggregate, the specified dataset scope.
What other things can we do to troubleshoot this issue? We are all using the same 2008R2 version.
I oftern get this "phantom" error when using the LookUp function. I call it phantom as no where can I find a reason, but there you have the error pop up.
The only way to get around it in my cases is to use the secondary function LookUpSet.
Hope I've helped.
Edit:
Furthermore you've intrigue me so I've done some research:
The lookup function is only for 1-to-1 relationship.
The loopupset funcrion is for 1-to-many relationship.
The multilookup function is for many 1-to-1 relationships, i.e. an array of single values where there is only 1 value in the second dataset. Not relevant but quite interesting.
Also I came across a potential fix. This being on the new machines try and open the datasets in the report and refresh all fields in the dialog box. For some reason this may relink the fields to this expression. Go figure...Blockquote