SQL Server Reporting Services for Application Developers – Attendees pick topics Kevin S. Goff
Kevin S. Goff – Brief BIO Developer/architect since 1987 / Microsoft SQL Server MVP Columnist for CoDe Magazine since 2004, “The Baker’s Dozen” Productivity Series”, 13 tips on a SQL/BI topic Wrote a book, collaborated on a 2 nd book Frequent speaker for SQL Server community events and SQL Live!360 Conferences My site/blog: (includes SQL/BI webcasts) Releasing some SQL/BI video courseware in SSRS for Developers
Attendees pick topics 1.SSRS Drilldown capabilities 2.Running Totals 3.Matrix capabilities 4.SSRS Data Driven Subscriptions 5.Putting an SSRS report on an ASP.NET webpage 6.Launching an SSRS report and exporting to PDF from inside an SSIS package 7.Interactive sorting 8.Building Charts with dual-Y axis definitions 9.Generating Performance Gauge and sparkline data visualizations 10.Implementing multi-valued parameter selections with a stored procedure 11.Subreports 12.Launching child report from parent report as a Report Action 13.Nested page groupings/pagination 14.Hiding columns based on user input or based on user security/authentication 15.Reporting against OLAP cubes 16.Building charts with multiple data series
1 - SSRS Drilldown capabilities Initially everything collapsed, based on initial parameter settings User can expand Grand Total label to show ship methods, and expand ship methods to see Vendors
1 - SSRS Drilldown capabilities To implement drilldown, there’s no actual drilldown feature Instead, it’s a matter of hiding a group level, and toggling the visibility based on a parent label For the Group, go to Visibility, and set the Toggle Item to a label at the parent level To initially suppress the group level, set Visibility “when report is initially run” to false. Or it can be based on report user parameter References textbox
1 - SSRS Drilldown capabilities And then to implement at further child levels, same concept Set toggle item to the label used for the parent group
2 – Running Totals (Running Aggregations) To implement running aggregation values, using the function RunningValue First Parameter is the column value being aggregated Second parameter is the aggregation (sum, Avg, Max, etc.) Third parameter is the scope of the aggregation (the group)
3 – Matrix capabilities Matrix example Years across the top, even though we don’t know how many years there could be The column group could be markets, or products, or quarters, etc. Matrix option for % of Total Years spread across in reverse order % of total based on sales with respect to totals across all years for the single shipper, or totals across all shippers for the year
3 – Matrix capabilities Matrix example Years across the top, even though we don’t know how many years there could be The column group could be markets, or products, or quarters, etc. We can insert columns inside the matrix to show more data or calculations The two calculation expressions (for % of row or column total) are expressions within the row/column group Result set columns for Shipper and OrderYear defined as Row and Column Groups The SUM aggregation will occur for the scope of shipper/orderyear
3 – Matrix capabilities The % of Total Calculations can refer to textboxes that are part of a spreading element column group
4 – Data Driven Subscriptions Requirement: must use SQL Server Agent! One report, many recipients for different parameters, on a schedule One report, many output destinations for different parameters, on a schedule We can populate a relational control table in SQL Server with information to drive the report subscription SSRS web interface will prompt us for necessary fields The source of data for the report (as well as the data source for the relational control table that contains the subscription information) must have credentials securely on the server (for unattended execution) This can be a time saver – if you have a large # of recipients Also dynamic – will pick up changes when we insert new rows to the relational control table Can be UNC location, or SharePoint Document Library, or address MHTML, Excel, PDF, TIFF, CSV, etc Relational source: Key parameters OLAP source: dimension key Generated output name
4 – Data Driven Subscriptions Must provide source for the table holding subscription information Credentials must be stored securely
4 – Data Driven Subscriptions Interface will detect the parameters required by the report when it’s run unattended We can use our mapping table (note the first parameter was generally called “Param1”)
4 – Data Driven Subscriptions Next, provide the delivery method Then provide SSRS with all the columns from our mapping table, that correspond to the subscription requirements
4 – Data Driven Subscriptions Finally, provide a delivery event (preferably a shared schedule)
5 – SSRS Report on ASP.NET webpage Drop instance of SSRS Report Viewer on an ASP.NET webpage Also needs Script Manager We’ll need code in the code-behind to set report properties
6-Launching SSRS report inside an SSIS package C# code inside SSIS Script to run a report unattended.NET references required
7-Interactive sorting Runtime ability for user to sort on any column in the browser Design-time property in column header textbox, for Interactive Sorting
8-Charts with dual-Y axis definitions Chart plots two numeric columns on two different scales Helpful for plotting percentages on a different axis/scale Primary Y-Axis (sales in millions) Secondary Y-Axis, for percentages (since they need a different scale)
8-Charts with dual-Y axis definitions For the second measure, you can right-click to go to Properties for the data series, then go to the Axes and Chart Area Properties and set the vertical axis to secondary To render the percentages as a line instead of a bar chart, right- click and change the chart type
9-Performance Gauge/sparkline visualizations
10-Multi-valued parameters with stored procedure 1.Reporting Services passes a multi-valued parameter as a comma-separated string to a stored procedure 2.Must create a table-valued function in the database, to convert a CSV string to a table variable 3.Stored Procedure can receive the CSV string, call the TVF, and join the results to other tables
11-Subreports 1.A single report can only render one instance of a one-many relationship. 2.If there are multiple one-many relationships for multiple levels of detail, we need to implement subreports 3.Basically, we create a main report where the primary dataset contains a key (in this instance, a product key) that can be passed to two child reports as parameters 4.The 2 child reports are built with the expectation they’ll receive a product key parameter 5.Then in the main report, add them as subreports Multiple levels of detail Main report shows each product, and then within each product, sales from both internet sales and reseller sales
11-Subreports In the main report, add references to the two child reports as subreports In the subreport properties, reference the child report, and pass the Product Key from the main dataset as a parameter to the child subreport
12-Launch child report from parent report User clicks on state (Oregon), and report launches a 2 nd report (which shows sales for cities in Oregon) Can use Report Action feature in data point of main report to launch a second report, with parameters that the child report expects
12-Launch child report from parent report The connection point might be a textbox, or a data series point on a chart, or the Polygon properties of a map Find the Action Page, specify “Go to Report”, and define the child report. The interface will expose the parameters that the child report expects, and we can pass values from the main report
13-Nested page groupings/pagination Not only can SSRS show “Page X of Y”, it can also show pagination for groups within the report Just need to define some properties for the group
13-Nested page groupings/pagination For the group (in the properties sheet), need to define the Page Break properties Pagination won’t work correctly at the Group level unless we set these.
14-Hiding columns Column visibility Use SSRS global variable User!UserID to call a stored procedure to query a custom control table that holds rights definitions for specific columns SSRS does not have any built-in security feature to define whether users can see (or not see certain columns. But we can implement a custom solution using control tables based on User ID, and the SSRS column visibility feature
15 – Chart with Multiple Series SSRS for Developers30 These 2 bars represent 2 different series for the same month: Inventory and Shipments
SSRS for Developers31 Within each month, a category group definition for (I)nventory and (S)hipped (XAxisType) Series type that breaks out Shipped by multiple definitions (Green and Yellow) Series type that breaks out Inventory by multiple definitions (Cyan, Yellow, Red, Blue, Grey) An average (maybe average daily inventory for the month) rendered as a line chart Result set that drives chart 15 – Chart with Multiple Series