I created a report for SQL Server 2008 R2 Reporting Service, in design mode this report looks like :
You can see I have an expression in the left cell of second row from last, the expression is:
=CountRows("GroupbyClassification")
When I preview this report, it give me this error:
The value expression for the textbox ‘textbox7’ has a scope parameter that is not valid
for an aggregate function. The scope parameter must be set to a string constant that is
equal to either the name of a containing group, the name of a containing data region, or
the name of a data set
This error is caused by CountRows("GroupbyClassification"), from
http://technet.microsoft.com/en-us/library/dd255215(v=sql.105).aspx you can see CountRows can work on a group. But why it doesn't work for me. If I just use CountRows(), it at least works without error.
It's because GroupbyClassification isn't the current or containing scope. It is the child scope. If you use =CountRows("GroupbyLocation"), it will give you the same results as =CountRows() because GroupbyLocation is the current scope. Since there are multiple GroupbyClassification Row Count values for each GroupbyLocation group, the report can't know which one to return when you specify the GroupbyClassification scope.
Child scopes can only be used in nested aggregates. So, you could use =sum(CountRows("GroupbyClassification")), but that would give you the same counts as =CountRows("GroupbyLocation") and =CountRows().
Related
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 parent report with a dynamic where clause, which is passed as $P!{WHERE_CLAUSE}, and the where clause in turn contains $P{} parameters
Eg: $P!{WHERE_CLAUSE}=> where docno between $P{P_FROMDOCNO} and $P{P_TODOCNO}
Values for $P{P_FROMDOCNO} and $P{P_TODOCNO} are also passed in the same execution
The parent report has a subreport, that summarizes based on certain category, whose query is based on the parent's where clause.
select vat,sum(amt) from tablename $P!{WHERECLAUSE} order by vat
So the where clause is passed to the sub-report using parameter mapping. But the subreport fails to read $P{P_FROMDOCNO} and $P{P_TODOCNO} values from the parent, resulting in empty document. All the above parameters have been mapped to the subreport parameters. The main goal is to fire the query in the database with bind parameters, even for the sub reports.
Kindly let me know if any solution for the above.
Edit: My question is not a duplicate of the mentioned question in the comments section. Because my subreport receives all the mapped parameter values, but the dynamic where clause($P!{WHERECLAUSE_SUB} which has the $P{P_FROMDOCNO} and $P{P_TODOCNO} fails to evaluate.
Thanks in advance,
Geetha
I have a report which creates a list of Events for a specified date range and event type.
The date range and event type are parameters defined in the report. The date parameters (#DateFrom and #DateTo) work as they should.
The #EventType parameter however, which is defined as a list of values provided by a DataSet (with 'Allow Multiple values' checked), does not provide the expected behaviour when using the {Select All} check box. If I select one or more Event Types by checking several boxes on the list, the report will show the Events which match the specified Event Types correctly.
However, if I click the {Select All} box (which then highlights all of the other possible values), the report does not show the Events for all of these Event Type values. It seems to miss out several of the values which are selected by the {Select All} box. If I run the report specifically for those missing values, the report returns events matching those types. This indicates to me that there is not a lack of data for these types.
And for that reason, it looks to me like the {Select All} is bugged...or perhaps cached somewhere? I've tried deleting the report/parameter dataset and redeploying to no avail. It's worth noting that this behaviour happens locally before deploying it, too.
Has anyone seen this before, or does anyone have any suggestions?
EDIT - I should also mention that the parameter in question (#EventType) has no default value assigned.
How are you declaring your predicate for the variable? It should be be like:
where thing in (#Variable)
Where #Variable is a multi value parameter.
You could attempt to see if the values of the multi valued parameters are junked up somewhere as well by defining them. Generally the collection method of multi valued parameters can cause issues if there data types are different.
Also you may try to design your data set at runtime to build instead of being a static query. EG: Set up an expression for your dataset like:
="Select * from table where thing in (" & Parameters!Variable.Value & ")"
This would cause the parameter to build as part of a string and then evaluate at run time instead of from a traditional query.
Can't quite believe that this was the case, but the parameter which was passed to the SQL Server procedure was too small. It was defined as a VARCHAR(500) and needed to be bigger to deal with a large list of comma separated values. I changed it to VARCHAR(4000) and it's now functioning as expected.
Thanks to Djangojazz for pointing me to the direction of the parameter.
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 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