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
Related
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().
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 would like to create a team query for our TFS users that shows all task items where the sum of the [hours remaining] and [hours completed] fields exceed the [original estimate] value.
Now Whilst I can add a clause to the WIQL that compares one field to the value of ONE other field (Which I had to ask you kind folks in stack exchange how to do in How do I write a TFS 2010 Work Item query clause whose value is a field value? which was answered by PVitt with admirable politeness - Since I had simply failed to read the "operator" drop down properly!)
I am struggling to find a way of querying the sum of two fields.
For example:
This query clause works;
And Completed Work > [Field] Remaining Work
What I really want is something along the lines of;
And Completed Work > [Field] Remaining Work+Original Estimate
The problem is either this cannot be done, or my wild guesses as to the correct syntax for summing two field values have all been wrong.
Specifying two filenames separated with a + just yields a TF51005 error
Similarly guessing at a "macro" like Sum(Remaining Work+Original Estimate) or Sum(Remaining Work,Original Estimate) results in the same.
So is this even possible?
if it is how would I go about this?
What you want is not possible. Your options are to use:
1) the object model to write C# code that iterates over the work items from a query and do the math yourself
2) run the query in excel and do the calculations and filter in excel
3) use ssrs to create a report that does the math for you
If you think this is important, you can always post your suggestion on user voice: https://visualstudio.uservoice.com
Add a new hidden field to store the sum, install TFS Aggregator and set it up to update the hidden field when the workitem is updated.
Then perform your queries off the new field.
There may be a couple of minutes delay between updating the sum having the new value.
<AggregatorItem operationType="Numeric" operation="Sum" linkType="Self" workItemType="Task">
<TargetItem name="Total Work"/>
<SourceItem name="Remaining Work"/>
<SourceItem name="Original Estimate"/>
</AggregatorItem>
If you're soley focused on the results/don't mind a (short) trip outside TFS, what I do is run the TFS query that produces the individual results I need, then just select all/copy/paste the results grid into Excel. There you'll have access to all Excel's suming and auto (col headers)/advanced filtering capabilities. You can define criteria that reference other cells using this method as well. Can also use the "If()" fcn to (in/ex)clude cell values in straight formulas. W/ some Excel fancy footwork, should even be able to preserve the summing fcns btw runs/pastes.
I'm using Crystal Reports XI. We use Crystal Reports embedded into a share point site written in C#/ASP.net. Our web developers instatiate a report in code and pass the selection criteria by appending to the Select Formula object.
The problem I'm running in to is that when I use a SQL Command Object, the selection formula is not being passed to the sql server as a where clause. This causes the entire result set to be queried and then limited on the server. For very large tables, this is causing a significant performance hit.
Here's an example:
SELECT foo.id, foo.code, foo.name
FROM foo foo
Select criteria is shown as:
{Command.name} like "someName"
If I then run the report the entire foo table is queried and then crystal reports limits from the entire set.
If instead I do it based on the table without a command object, the WHERE clause is appended to the sql query and all the limiting is done at the db level.
I'm assuming this occurs because a SQL command could potentially be very complex and adding a WHERE clause to the bottom isn't always possible. My question then, is there any good way to force some sort of pass through. Should I be talking to the C# devs and asking them to rework the way we pass parameters?
Thanks for any help and discussions.
A record-selection formula is never added to the Command-object's query.
I'm not certain if the CR SDK supports Command object modification (I know it supports read-only access, however).
The Command object does support parameters (in 2008, they can be multi-valued parameters) which can be accessed programmatically (they are converted to Parameter Fields in the report).
I'm assuming that you are using a Command object because of the query's complexity. If you can push the complexity to a SQL view, then use the 'visual linking' expert to create your query, you'll have more flexibility.