Best practice for single-valued result in SSRS 2012 - ssrs-2012

I'm new to Reporting Services and using SQL Server Data Tools (Visual Studio 2012). I want to add an item that will display a single value - in this case, the result of a stored procedure call. The value would probably be displayed in the report header.
I've looked at the Tablix data parts that can be added to the report: table, list, and matrix. Not sure which of them, if any, would be appropriate. I could add a parameter item, but it seems that these function as user input choices.
I also looked at a read-only text box, but don't see how to populate it with a query result.
What is the accepted method of adding a single-value result to a report?

If this is to be displayed in the page header, your only option is a textbox; you can't add tablix type parts to page headers/footers.
The textbox expression would be something like:
=First(Fields!MyValue.Value, "DataSet1")
By using an aggregate expression like this you can make sure only one value is returned (even though you might always have only one) and you can also specify the aggregate's Scope; in this case the DataSet you want to query.
If this was going in the report body I would still recommend the same approach, though I wouldn't go so far as to call it best practise, any would work so it's really personal taste.
However, if you had multiple fields returned by the SP but still only one row, in that case I would recommend a table style tablix with one header-level row; easiest to maintain and layout.

Related

SSRS Dropdown 'Any' Value not working

new to this world so looking for help with what I think wold be a simple thing to fix, however me and the guy who is training me on all that is SQL and SSRS cannot figure this out
I have a report within SSRS and SQL which is working perfectly bar one thing
I have a drop down list parameter which has all our customers names, and the report shows volumes of what that customer has obtained so far etc, and for an individual customer, this works perfectly. However, when trying to see the total volumes by choosing 'Any' from the drop down list, it returns no data, rather than returning everything
Can anyone please advise what I could be missing here, or what I need to show you to help resolve this issue
Cheers
Liam
Assuming you Stored Proc parameter is varchar and represents either customer names or an 'Any' value then the following should work.
SELECT myField1, myField2 -- etc
FROM myTable t
WHERE (t.ClientName = #myParameterName OR #myParameterName = 'Any')
Optionally Please Note: Personally I don't use SPs and usually just put the code to grab the data in the dataset. Some companies don't like you doing this but if you are able to do this I think this makes life easier.
If you can put the stored proc code directly in your dataset query then you can make the report more flexible. You can change your parameter to be MultiValue, you don't need and 'Any' value added to your parameter list either and then you can simply do something like
SELECT myField1, myField2 -- etc
FROM myTable t
WHERE t.ClientName IN(#myParameterName)
SSRS will take all the selected parameter values and inject them into the dataset query correctly, so there is nothing else you need to do. SSRS will also add a 'Select All' option to your parameter in case you want to gran data for everything. The report will work for 1, 2, 10 or all client names.

How to implement dynamic datasets in a SSRS report

I have the following scenario: a single .rdl file with a stored procedure as datasource. This stored procedure accepts two parameters: #ProcedureName nvarchar(max) and #Parameters xml. The functionality of the stored procedure is to call another stored procedure (most probably on a different database) with the given XML parameters. So, in essence, each of the stored procs that gets executed will return it's own dataset.
How would I go about creating a tablix/matrix that consumes the dataset without specifying the columns as the columns need to get generated at runtime?
Unfortunately, SSRS doesn't have "AutoGenerateColumns"-style functionality and resolves a number of things at design time. So the short answer is that you cannot.
The designer checks field references when saving, and will not save with a reference to a field that isn't in a dataset's field list. If a field ceases to exist after the report definition is generated, it will show up as a static blank value on the report. Expressions will do so as well, even if the field is in an unevaluated portion. So if field B is removed, this expression would still be affected:
=IIF(1=1,Fields!A.Value,Fields!B.Value)
Which means that you can't use conditional grouping expressions as a workaround, even if you had an exhaustive list of the columns that might be returned.

How to loop design in SSRS report

I have a report design that have been used for a while.
Now i want to create multiple pages of the same report looping with different records.
Is there any way to do this, to loop the design..
either looping it how to get the lookup-function to register as a valid function in an expression.
I use two datasets in the report
I started by making one tablix cell and putting the entire design into this one cell, which worked nice, except i have to use one tablix with "Dataset2" and it doesn't allow me to do this because if they are nested, the inner scope has to use the same dataset as the outer scope.
The report designer can't recognize the "lookup" function which i try to put in a expression of this tablix, and using a subreport for such a small task seems like too much.
Any ideas?
Here's a quick screenshot of what I'm working with:
Everything uses dataset1 except that one tablix that needs to be dataset2...
Heres a image of my lookup-function that gives an error:
ok i got this right.
If you want to loop a single page ssrs design put the whole design in a 1x1 tablix with grouping on whatever parameter you like.
If any part of your design use data from another dataset inside of this tablix, you have to use a sub report...
It isn't that much work, but to get the correct parameter in i actually had to make a report data provider and contract + design for the subreport(which just consisted of a single table) which was a pain in the ass. none the less it worked, and all is good.

how can I get the count of matches for filters of jqgrid

I have pulldown select box for filtering the jqgrid (not using the builtin navbar, and data is local). I'd like to grey out the ones that have no matches in the grid.
Is there a way to perform the query to just get the count without updating the ui rows so I can initialize/update the pulldown to enable only those with matches (or even better to supply the number of matches in the menu)
EDIT:
To clarify I want to disable/greyout my filter menu items not the table row items
Internally jqGrid uses $.jgrid.from method to apply the filter to the data. What you want to implement it's probably not just getting the counts because you wrote:
I'd like to grey out the ones that have no matches in the grid.
Nevertheless all want you want is possible to implement. You will have to write some JavaScript code which uses $.jgrid.from($("#list")[0].p.data) for initialization. Then you have to construct the query using methods like contains, lessOrEquals, andNot, orNot and so on. Then you should apply the query with respect of var queryResults = query.select();. If you examine ids in the queryResults you can make gray all items which are not in the set.
I recommend you to read and to debug the addLocalData method of jqGrid and which contain all what you need. Moreover I recommend you to set breakpoint on the line and examine match and results variables. It this is not simple of cause, but if you need some individual solution you have to invest time in it.
UPDATED: I though more about the described problem. My recent answer with the demo demonstrate how you can solve your problem.

Using parameters in reports for VIsual Studio 2008

This is my first attempt to create a Visual Studio 2008 report using parameters. I have created the dataset and the report. If I run it with a hard-coded filter on a column the report runs fine. When I change the filter to '?' I keep getting this error:
No overload for method 'Fill' takes '1' argument
Obviously I am missing some way to connect the parameter on the dataset to a report parameter. I have defined a report parameter using the Report/Report Parameter screen. But how does that report parameter get tied to the dataset table parameter? Is there a special naming convention for the parameter?
I have Googled this a half dozen times and read the msdn documentation but the examples all seem to use a different approach (like creating a SQL query rather then a table based dataset) or entering the parameter name as "=Parameters!name.value" but I can't figure out where to do that. One msdn example suggestted I needed to create some C# code using a SetParameters() method to make the connection. Is that how it is done?
If anyone can recommend a good walk-through I'd appreciate it.
Edit:
After more reading it appears I don't need report parameters at all. I am simply trying to add a parameter to the database query. So I would create a text box on the form, get the user's input, then apply that parameter programmatically to the fill() argument list. The report parameter on the other hand is an ad-hoc value generally entered by a user that you want to appear on the report. But there is no relationship between report parameters and query/dataset parameters. Is that correct?
My last assumption appears to be correct. After 30 years in the industry my bias is to assume a report parameter actually filters the SQL data using the given parameter. This is not the case with .rdlc files used by Report Viewer. These report parameters have nothing to do with fetching data. Sounds like this was a design decision on Microsoft's part to completely separate the display of data from the fetching of data, hence, Report Viewer has no knowledge of how data may be fetched. Best way for me to conceptualize this dichotomy is to think of Report Parameters more as Report Labels, quite distinct from the dataset query parameters.

Resources