{"id":1916,"date":"2014-12-03T00:00:00","date_gmt":"2014-12-03T00:00:00","guid":{"rendered":"https:\/\/test.simple-talk.com\/uncategorized\/sql-server-reporting-services-basics-the-visual-controls\/"},"modified":"2021-05-17T18:33:16","modified_gmt":"2021-05-17T18:33:16","slug":"sql-server-reporting-services-basics-the-visual-controls","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/bi-sql-server\/sql-server-reporting-services-basics-the-visual-controls\/","title":{"rendered":"SQL Server Reporting Services Basics: The Visual Controls"},"content":{"rendered":"<div class=\"article-content\">\n<p> \tThis is the third article in a four-part series on SQL Server Reporting Services 2012 (SSRS). <a href=\"https:\/\/www.simple-talk.com\/sql\/reporting-services\/sql-server-reporting-services-basics-building-ssrs-reports\/?utm_source=simpletalk&amp;utm_medium=weblink&amp;utm_content=ssrsbasics3\">Part 1<\/a>, <em>Building Basic Reports<\/em>, provided a step-by-step guide to basic report creation and <a href=\"https:\/\/www.simple-talk.com\/sql\/reporting-services\/sql-server-reporting-services-basics-customizing-ssrs-reports\/?utm_source=simpletalk&amp;utm_medium=weblink&amp;utm_content=ssrsbasics3\">Part 2<\/a>, <em>Customizing SSRS Reports<\/em>, took a tour of some of the core SSRS features and functions that you&#8217;ll need to develop dynamic reports. In this article, you will learn about the rich set of visual features included with SSRS. <\/p>\n<p> \tStarting with SSRS 2005, Microsoft has included a scaled-down version of the <a href=\"http:\/\/www.dundas.com\/\">Dundas Chart Control<\/a>. Starting with 2008 R2, SSRS has an impressive set of visual controls including gauges, indicators, sparklines, and maps. For many people, these features alone offer a compelling reason to adopt SSRS and upgrade to at least 2008 R2. <\/p>\n<h1>Getting Started<\/h1>\n<p> \tIn order to work through the examples, you will need to have installed and configured SQL Server 2012, SQL Server 2012 Reporting Services, and SQL Server Data Tools (SSDT). The examples will also work with the 2008 R2 version of Reporting Services, in which case you will need Business Intelligence Development Studio (BIDS) instead of SSDT for report development. For further details, please refer back to the <em>Installing and Configuring Reporting Services<\/em> section of the previously-referenced <em>Building Basic Reports<\/em> article. The examples will also work with SQL Server 2014, since there were no significant changes in report development with this release. <\/p>\n<p> \tThe code bundle for this article (see the <em>Code Download<\/em> link in the speech bubble to the right of the article title) contains all the files you need to get started. You&#8217;ll need to create the <code>ReportDemo<\/code> database, by running the <code>ReportingDemoDatabaseScript.sql<\/code> script. <\/p>\n<p> \tThis article assumes that you understand the basics of creating reports, data sources, datasets, parameters, and grouping. If not, please review parts 1 and 2 of this series before proceeding. <\/p>\n<h1>Basic Charts<\/h1>\n<p> \tSSRS is great for displaying data in a tabular or matrix format. You can add hierarchical grouping levels and totals. However, sometimes a picture is worth a thousand words, and as a report developer you will often be asked to display the data in an easily-digestible, visual format. The most basic way to display data, for example &#8216;sales by year&#8217; or &#8216;sales by territory&#8217; is with a chart. <\/p>\n<h2>Creating a basic chart<\/h2>\n<p> \tLaunch SSDT, or BIDS if you are running an earlier version of SSRS, and create a new report server project called <code>ChartProject<\/code>. Add a shared data source, <code>ReportDb.rds<\/code>, which points to the <code>ReportingDemo<\/code> database to the project. <\/p>\n<p> \tThe goal is to design a report that will display the total value of customer purchases on a given date. Add a new report called <code>MyChart.rdl<\/code> to the project (right click <strong>Reports<\/strong>, select <strong>Add<\/strong> | <strong>New item<\/strong>). Highlight the chart report and then from the left-hand <strong>Report Data<\/strong> menu, add a data source called <code>ReportDb<\/code> that references the <code>ReportDb<\/code> shared data source. Set up an embedded dataset for the report based on <code>ReportDb<\/code> and using the following query, which fetches various bits of information pertaining to customer purchases, including the field we wish to &#8220;measure&#8221;, <em>i.e.<\/em><strong>PurchaseAmount<\/strong>, over time (<strong>PurchaseDate<\/strong>). <\/p>\n<pre class=\"lang:tsql theme:ssms2012\">SELECT Purchase.PurchaseID ,\n       Purchase.CustomerID , \n       Purchase.PurchaseDate , \n       Purchase.PurchaseType , \n       Purchase.PurchaseAmount , \n       Customer.FirstName + ' ' + Customer.LastName AS CustomerName \nFROM   Purchase \n       INNER JOIN Customer ON Purchase.CustomerID = Customer.CustomerID\n<\/pre>\n<p class=\"caption\"> \tListing 1 <\/p>\n<p> \tOn your new report, expand out the design area so that you have room to work, and then drag onto the design area a chart control. When prompted to select a chart type, select the basic column chart, as shown in Figure 1, and click <strong>OK<\/strong>. <\/p>\n<p class=\"illustration\"> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2105-1-c69d3b1f-6c30-4eee-adf2-452a88cda749.png\" alt=\"2105-1-c69d3b1f-6c30-4eee-adf2-452a88cda\" \/><\/p>\n<p class=\"caption\"> \tFigure 1 <\/p>\n<p> \tAs you can see there are many available chart types, including some 3D charts. In my experience, 3D rendering can distort the heights of the columns, so use caution. Simpler is usually better. <\/p>\n<p> \tHaving selected the chart type, the <strong>Chart Data<\/strong> window pops open, as shown in Figure 2. This is where you will add the fields to be measured. <\/p>\n<p class=\"illustration\"> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2105-1-c1885f64-86e3-4958-9cd8-c390bcf94881.png\" alt=\"2105-1-c1885f64-86e3-4958-9cd8-c390bcf94\" \/><\/p>\n<p class=\"caption\"> \tFigure 2 <\/p>\n<p> \tThe <strong>&#226; Values<\/strong> section is where you add the summary value for the chart, such as &#8220;total sales&#8221;. On a bar chart like this one, the field you add here will control the height of the bars. SSRS will calculate an aggregate value for the field added to this section, such as a sum (the default), or a count. <\/p>\n<p> \tAlong the horizontal axis, several bars will be displayed. The <strong>Category Groups<\/strong> section controls the data represented by each of the bars. Generally, it is a limited set of data, such as several years, the months of one year, territories, or departments. In additions, the <strong>Category Group Properties<\/strong> allow you to, for example, add filters or change the sort order of the category field. <\/p>\n<p> \tNotice that there is also a section called <strong>Series Group<\/strong> that you can use to break out the data by series as well as category. You will see how to use <strong>Series Groups<\/strong> a little later in this section. <\/p>\n<p> \tClick the yellow plus sign and add the <strong>PurchaseAmount<\/strong> field into the &#226; Values section and make sure that the <code>SUM<\/code> function has been applied. You can change the aggregate function by clicking the down area next to the aggregate expression, selecting <strong>Aggregate<\/strong> and then selecting a different function. <\/p>\n<p> \tSince you&#8217;re working with such a small data set, you&#8217;ll simply use <strong>PurchaseDate<\/strong> for the category group, so SSRS will group on this field, and present the total purchase amount by date. If you wanted to show the purchase amount by year instead of date, I suggest changing the original query to an aggregate that totals the sales, and then groups by <code>YEAR(PurchaseDate)<\/code>. <\/p>\n<p> \tTo display the total purchase amount on the chart by purchase date, change <strong>(Details)<\/strong> to <strong>PurchaseDate<\/strong>. The Chart Data windows should look like Figure 3. <\/p>\n<p class=\"illustration\"> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2105-1-06c78147-9755-4adc-85e2-088668c2f82a.png\" alt=\"2105-1-06c78147-9755-4adc-85e2-088668c2f\" \/><\/p>\n<p class=\"caption\"> \tFigure 3 <\/p>\n<p> \tExpand the size of the chart two or three times. Save the report and navigate to the <strong>Preview<\/strong> tab to run the report. It should look as shown in Figure 4. <\/p>\n<p class=\"illustration\"> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2105-1-a9a88392-ca98-4c5f-82c3-b73bfec6f0f2.png\" alt=\"2105-1-a9a88392-ca98-4c5f-82c3-b73bfec6f\" \/><\/p>\n<p class=\"caption\"> \tFigure 4 <\/p>\n<p> \tThis report shows total sales by purchase date, but what if it needed instead to show the sales by date for different types of purchase, such as online purchases, versus in-store purchases, and so on. You can achieve this by adding the <strong>PurchaseType<\/strong> field as a Series Group. For every field in the <strong>Values<\/strong> area, we&#8217;d see a series of bars, each one representing a distinct value that exists in the <strong>Series Group<\/strong> field. So, for example, if the <strong>PurchaseType<\/strong> field contains three distinct types of purchase, then you&#8217;ll see three series for each field in the <strong>Values<\/strong> area. <\/p>\n<p> \tIn the <strong>Series Groups<\/strong> section of the chart&#8217;s data properties, click the plus sign and add <strong>PurchaseType<\/strong>. Preview the report again, and you should see the data displayed based on the type of purchase. <\/p>\n<p class=\"illustration\"> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2105-4572a8f8-7508-4ad5-8a4e-1460ebfe4e1e.png\" alt=\"2105-4572a8f8-7508-4ad5-8a4e-1460ebfe4e1\" \/><\/p>\n<p class=\"caption\"> \tFigure 5 <\/p>\n<h2>Formatting the Chart<\/h2>\n<p> \tYou now have a chart, but, there is still work to do in order to get it into a nice format. For a start, the date format does not look good, so fix that first. On the <strong>Design<\/strong> tab of the report, right-click the text area along the bottom of the chart that says &#8220;Purchase date A&#8221; and bring up the <strong>Horizontal Axis Properties<\/strong> dialog. Select the <strong>Number<\/strong> option from the left menu, and then the <strong>Date<\/strong> category. Select the appropriate date format and click <strong>OK<\/strong>. You can make the same type of change to the vertical axis if needed, for example formatting it as currency. Often the numbers on the vertical axis are very large and it might help to display the values as thousands, for example. <\/p>\n<p> \tModify the title at the top of the chart and then remove or modify the axis titles. If you wish to change the sort order of the <strong>Category Group<\/strong> field, click the dropdown box next to the category, select the Category Group Properties and navigate to the <strong>Sorting<\/strong> section. To change the color of the bars, right-click the one of them to get to the properties. After tweaking the properties, my report looks like Figure 6. <\/p>\n<p class=\"illustration\"> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2105-1-4ebbb27b-8ef7-4731-98b6-7d649d8fabce.png\" alt=\"2105-1-4ebbb27b-8ef7-4731-98b6-7d649d8fa\" \/><\/p>\n<p class=\"caption\"> \tFigure 6 <\/p>\n<h2>Chart types<\/h2>\n<p> \tAs noted earlier, the chart control can produce a variety of the different chart types. To switch to a different type, simply right-click on the chart (in the <strong>Design<\/strong> tab) and use the <strong>Change Chart Type<\/strong> option. <\/p>\n<p> \tFirst, remove the Series Group (right click <strong>PurchaseType<\/strong> and select <strong>Remove Series Group<\/strong>) and try switching to a <strong>Smooth Line<\/strong> chart, the second of the line chart types. Right-click the series line and choose <strong>Series Properties<\/strong>. On the <strong>Series Data<\/strong> page, select <strong>[Sum(PurchaseAmount)]<\/strong> in the <strong>Tooltip<\/strong> dropdown box. On the <strong>Markers<\/strong> page, change the <strong>Marker Type<\/strong> to <strong>Circle<\/strong> and click <strong>OK<\/strong>. <\/p>\n<p> \tNow when you run the report, hovering the mouse over a data point should reveal its value as a tooltip. You can format the ToolTip value by changing the Tooltip property to an expression that uses the <strong>FormatCurrency<\/strong> function: <strong>FormatCurrency(Sum(Fields!PurchaseAmount.Value))<\/strong>. Figure 7 shows how the report should look. <\/p>\n<p class=\"illustration\"> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2105-1-a5fe9e16-986b-43d6-9508-7d1b3b299b60.png\" alt=\"2105-1-a5fe9e16-986b-43d6-9508-7d1b3b299\" \/><\/p>\n<p class=\"caption\"> \tFigure 7 <\/p>\n<h1>Indicators<\/h1>\n<p> \tSo far you have looked at charts to compare data over time, or by some other measure. You can also add visual elements to regular report sections. One visual element you can add is called an Indicator, which is generally used to provide a simple, visual signal of success or failure. For example, an indicator could show an upward arrow if a goal is met, a horizontal arrow if it is close, and a downward arrow if the goals was missed by a wide margin. <\/p>\n<p> \tCreate a new report called <code>Indicators.rdl<\/code> with the same data source and dataset (Listing 1) as the <code>MyChart<\/code> report. Drag a table control into the report design area, and populate it with the <strong>PurchaseDate<\/strong>, <strong>CustomerName<\/strong> and <strong>PurchaseAmount<\/strong> fields. Format the report (highlight the header row and hit F4 to set the font and background color), then and add a new column to the right, as shown in Figure 8. <\/p>\n<p class=\"illustration\"> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2105-1-af03d592-74bf-4447-b915-d37d908b4db5.png\" alt=\"2105-1-af03d592-74bf-4447-b915-d37d908b4\" \/><\/p>\n<p class=\"caption\"> \tFigure 8 <\/p>\n<p> \tDrag an <strong>Indicator<\/strong> control to the empty cell and use the automatic <strong>Select Indicator Type<\/strong> dialog box to choose one of the indicator types. It is a good practice to select an indicator that changes shape, as well as color, depending on the value. If the shapes are identical, then the colors are lost when printed on a non-color printer. There are also many color blind people who can&#8217;t distinguish all colors. <\/p>\n<p> \tThe Indicator can be set to one value, the one that you want to measure. Click the indicator control to open the <strong>Gauge Data<\/strong> window and select <strong>PurchaseAmount<\/strong> as the indicator value. SSRS will automatically apply a <strong>Sum<\/strong> expression. <\/p>\n<p class=\"illustration\"> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2105-1-ef415f0f-8b10-4cc4-9cbd-9947d453cd54.png\" alt=\"2105-1-ef415f0f-8b10-4cc4-9cbd-9947d453c\" \/><\/p>\n<p class=\"caption\"> \tFigure 9 <\/p>\n<p> \tPreview the report and you should see an indicator, with the default properties, revealing at a glance the low, mid-range and high value sales, as shown in Figure 10. <\/p>\n<p class=\"illustration\"> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2105-1-57a8f45b-9911-4157-8e19-3ca6ef718cd8.png\" alt=\"2105-1-57a8f45b-9911-4157-8e19-3ca6ef718\" \/><\/p>\n<p class=\"caption\"> \tFigure 10 <\/p>\n<p> \tBy default, the indicator is based on percentages and distributed by thirds, but the properties of the indicator are very customizable. On the design view, right-click the indicator, select <strong>Indicator Properties<\/strong>, click <strong>Values<\/strong> and <strong>States<\/strong> where you can customize the values or percentages that determines which indicator to display. Figure 11 shows the default properties. <\/p>\n<p class=\"illustration\"> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2105-1-3dd651e2-5b0f-47ff-b00c-b205f2019f7d.png\" alt=\"2105-1-3dd651e2-5b0f-47ff-b00c-b205f2019\" \/><\/p>\n<p class=\"caption\"> \tFigure 11 <\/p>\n<p> \tYou can alter the percent ranges, switch to specific values instead, modify the colors and indicators, or even add additional indicators for more ranges. <\/p>\n<h1>Gauges<\/h1>\n<p> \tThe gauge is a slightly more complex control that compares the data to a set goal. Again, though, its basic purpose is to allow a manager to see quickly the progress towards a given goal. <\/p>\n<p> \tSay you&#8217;re asked to provide a manager with a report that will tell him or her quickly whether or not the team is on track to meet a yearly sales target. Create a new report called <code>Gauge<\/code> with the same <code>ReportDb<\/code> data source. The data set just needs to include the field to measure, in this case the <strong>SUM(<\/strong><strong>[<\/strong><strong>PurchaseAmount<\/strong><strong>])<\/strong>, broken down by year, so use the query in Listing 2. <\/p>\n<pre class=\"lang:tsql theme:ssms2012\">SELECT    YEAR([PurchaseDate]) AS PurchaseYear , \n          SUM([PurchaseAmount]) AS Amt \nFROM      [Purchase] \nGROUP BY  YEAR(PurchaseDate)\n<\/pre>\n<p class=\"caption\"> \tListing 2 <\/p>\n<p> \tAdd a table control to the report containing both of the fields. In the third data cell, drag in a gauge control. When prompted to select a gauge type, choose the first Linear gauge. Expand the width and height of the cell containing the gauge and format the report so that it looks similar to Figure 12. <\/p>\n<p class=\"illustration\"> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2105-1-c5413c1b-5114-451c-9d35-2b6a7ed6fe4c.png\" alt=\"2105-1-c5413c1b-5114-451c-9d35-2b6a7ed6f\" \/><\/p>\n<p class=\"caption\"> \tFigure 12 <\/p>\n<p> \tAt a minimum, you must set the value to measure, so click on the gauge to open the <strong>Gauge Data<\/strong> window and select <strong>Amt<\/strong> from the list. Once again, SSRS applies the <strong>SUM<\/strong> aggregate function automatically. <\/p>\n<p> \tRight now, the gauge resembles a Celsius thermometer at 10 degrees. If you run the report now, all of the values will be at 100 since the amounts are all over 100, as shown in Figure 13. <\/p>\n<p class=\"illustration\"> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2105-1-58692d14-c4a7-4e65-a864-339096f18c1c.png\" alt=\"2105-1-58692d14-c4a7-4e65-a864-339096f18\" \/><\/p>\n<p class=\"caption\"> \tFigure 13 <\/p>\n<p> \tTo alter the scale and the range (the red area), return to the <strong>Design<\/strong> tab. Right-click the range to bring up the <strong>Linear Scale Range Properties<\/strong> dialog box. Change the <strong>Start range scale value<\/strong> to 0 and <strong>End range at scale value<\/strong> to 1000. On the <strong>Fill<\/strong> properties, change the <strong>Color<\/strong> to <strong>Red<\/strong> and the <strong>Secondary Color<\/strong> to <strong>Green<\/strong>. Click OK. <\/p>\n<p> \tNext, right-click on the scale and bring up the <strong>Linear Scale Properties<\/strong> dialog box. On the <strong>General<\/strong> tab, set the Maximum value to 1000. Click <strong>OK<\/strong> and now preview the report as shown in Figure 14. <\/p>\n<p class=\"illustration\"> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2105-1-c75e12d8-e807-469c-a464-a2a8648d1844.png\" alt=\"2105-1-c75e12d8-e807-469c-a464-a2a8648d1\" \/><\/p>\n<p class=\"caption\"> \tFigure 14 <\/p>\n<p> \tYou can also add a gauge control to the report, outside of the table. In this case, the gauge will display the total aggregate value across the entire data set, in this case the total purchase amount over all years. <\/p>\n<p> \tAdd a gauge control to the report area, and select the default type. Set the properties in a similar way as the previous example, but use 3000 for the maximum value of the scale and range. When you preview the report, the gauge should look similar to Figure 15. <\/p>\n<p class=\"illustration\"> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2105-1-09968bf4-e78b-4059-8bd0-02839375ebfd.png\" alt=\"2105-1-09968bf4-e78b-4059-8bd0-02839375e\" \/><\/p>\n<p class=\"caption\"> \tFigure 15 <\/p>\n<h1>Data bars and Sparklines<\/h1>\n<p> \tData bars and Sparklines allow you to add visual detail to a grouping level within a report. For example, say you want to add a visual element to the report that indicates the trend of the sales for each month. This is a perfect use case for the sparkline. If you also want a visual way to see the sales broken down by categories then you can use a data bar. <\/p>\n<p> \tCreate a new report called <code>SparklineDatabar<\/code>. Listing 3 show the query for the report. <\/p>\n<pre class=\"lang:tsql theme:ssms2012\">SELECT   YEAR([PurchaseDate]) AS PurchaseYear , \n         SUM([PurchaseAmount]) AS Amt , \n         MONTH(PurchaseDate) AS PurchaseMonth , \n         PurchaseType \nFROM     [Purchase] \nGROUP BY YEAR(PurchaseDate) , \n         MONTH(PurchaseDate) , PurchaseType\n<\/pre>\n<p class=\"caption\"> \tListing 3 <\/p>\n<p> \tDrag a table to the report and add the <strong>Amt<\/strong>. Right-click on <strong>Amt<\/strong>, select <strong>Add Group<\/strong> | <strong>Row Group<\/strong> | <strong>Parent Group<\/strong>, group by <strong>PurchaseYear<\/strong> and check <strong>Add group header<\/strong>. Remove one of the empty columns. At this point, the report should similar to Figure 16. <\/p>\n<p class=\"illustration\"> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2105-1-f62b58f6-5a46-4a67-ae2c-da8d2dbff792.png\" alt=\"2105-1-f62b58f6-5a46-4a67-ae2c-da8d2dbff\" \/><\/p>\n<p class=\"caption\"> \tFigure 16 <\/p>\n<p> \tDrag a <strong>data bar<\/strong> control to the cell at the intersection of the third column and second row. Select the default type and click <strong>OK<\/strong>. Click the data bar to open up the <strong>Chart Data<\/strong> window which looks just like the window used in the regular chart earlier in the article. Select <strong>Amt<\/strong> for the summary value and <strong>PurchaseType<\/strong> for the category group. The properties should look like Figure 17. <\/p>\n<p class=\"illustration\"> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2105-1-94cef64b-1dbf-4163-9a20-eea25c6e0ab9.png\" alt=\"2105-1-94cef64b-1dbf-4163-9a20-eea25c6e0\" \/><\/p>\n<p class=\"caption\"> \tFigure 17 <\/p>\n<p> \tThe data bar control is essentially a small version of the chart control. Because it sits inside a cell, you cannot read the values or category. If the user of the report would like to see the values, you can add a tooltip. To do this, click twice in the cell with the data bar to select the bars. Right-click and select <strong>Series Properties<\/strong>. Click the <strong>Fx<\/strong> button next to the <strong>Tooltip<\/strong> property. Enter this expression: <\/p>\n<pre class=\"lang:tsql theme:ssms2012\">=Fields!PurchaseType.Value &amp; \": \" &amp; FormatCurrency(Fields!Amt.Value,0)\n<\/pre>\n<p> \tClick OK twice to close both dialogs and then preview the report. Remember to mouse over the bars to see the tooltip. The report should look like Figure 18. <\/p>\n<p class=\"illustration\"> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2105-1-e9ec309d-7208-4601-bdf5-bc1601efd2dd.png\" alt=\"2105-1-e9ec309d-7208-4601-bdf5-bc1601efd\" \/><\/p>\n<p class=\"caption\"> \tFigure 18 <\/p>\n<p> \tNow back in the <strong>Design<\/strong> tab, add another column to the table. This time drag in a <strong>sparkline<\/strong> control to the cell next to the data bar and choose the first <strong>Line<\/strong> type. This time the category group should be <strong>PurchaseMonth<\/strong>. The data bar showed how the data was broken down by type of sale, but the sparkline will show how the data is broken down by month. Figure 19 shows how the properties should be set. <\/p>\n<p class=\"illustration\"> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2105-1-bc497527-8342-43e9-b0ea-d0fcc1dc2220.png\" alt=\"2105-1-bc497527-8342-43e9-b0ea-d0fcc1dc2\" \/><\/p>\n<p class=\"caption\"> \tFigure 19 <\/p>\n<p> \tThe tooltip expression for the sparkline&#8217;s <strong>Series Properties<\/strong> should be as follows: <\/p>\n<pre class=\"lang:tsql theme:ssms2012\">=MonthName(Fields!PurchaseMonth.Value) &amp; \": \" &amp; \nFormatCurrency(Fields!Amt.Value,0)\n<\/pre>\n<p> \tChange the <strong>Marker Type<\/strong> to <strong>Square<\/strong>. Preview the report. It should look like Figure 20. <\/p>\n<p class=\"illustration\"> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2105-1-22fa17d4-7f47-469a-a32b-78ff9b8a0be9.png\" alt=\"2105-1-22fa17d4-7f47-469a-a32b-78ff9b8a0\" \/><\/p>\n<p class=\"caption\"> \tFigure 20 <\/p>\n<h1>Maps<\/h1>\n<p> \tThe final type of visualization is probably the most interesting. You can add maps to your reports to display data geographically. In this section, you will just set up a simple map that shows the location of the sales, but the world is your limit here (pun intended). <\/p>\n<p> \tAdd a new report called <strong>Map<\/strong> with a dataset called <strong>MapData<\/strong>, defined by the query in Listing 4. <\/p>\n<pre class=\"lang:tsql theme:ssms2012\">SELECT   Purchase.PurchaseID , \n         Purchase.CustomerID , \n         Purchase.PurchaseDate , \n         Purchase.PurchaseType , \n         ISNULL(Purchase.PurchaseAmount, 0) AS Amt , \n         CASE WHEN PurchaseType IS NULL THEN 0 \n              ELSE 1 \n         END AS Sale , \n         State \nFROM     Customer \n         LEFT JOIN Purchase ON Purchase.CustomerID = Customer.CustomerID\n<\/pre>\n<p class=\"caption\"> \tListing 4 <\/p>\n<p> \tAdd a map control from the Toolbox. When you do, a wizard appears. On the first page, you select the source of spatial data. You can select the built-in maps from the Map Gallery, an ESRI shape file, or spatial data from SQL Server. Select the simplest choice, the <strong>Map Gallery<\/strong> and <strong>USA<\/strong><strong> by State Exploded<\/strong>. Click <strong>Next<\/strong>. <\/p>\n<p> \tThe following screen allows you to zoom in and crop. Youcan also add a <strong>Bing Maps layer<\/strong>. The Bing Maps layer is really cool, but it can distract from the meaning of the data. For now, accept the defaults on this screen and click <strong>Next<\/strong>. <\/p>\n<p> \tOn the <strong>Choose map visualization<\/strong> page, youselect the type of map, Basic, Color Analytical or Bubble. Select the <strong>Color Analytical Map<\/strong> and click <strong>Next<\/strong>. The next page is where you map a dataset to the map. Select the <strong>MapData<\/strong> dataset. <\/p>\n<p> \tOn the <strong>Specify the match fields for special and analytical data<\/strong> page, you will link a field from the map itself to a field in the dataset. The data in the middle section is from the map. The data in the lowest section is your data. You need to map the <strong>STUSPS<\/strong> field from the <strong>Spatial data<\/strong> section to the State field in the dataset, so check the Match Fields checkbox next to <strong>STUPS<\/strong>, and select the <strong>State<\/strong> field in the <strong>Analytical data<\/strong><strong>set fields<\/strong> section, as shown in Figure 21. <\/p>\n<p class=\"illustration\"> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2105-1-356f1ca8-a60b-48ac-95ae-5e84f24969a4.png\" alt=\"2105-1-356f1ca8-a60b-48ac-95ae-5e84f2496\" \/><\/p>\n<p class=\"caption\"> \tFigure 21 <\/p>\n<p> \tClick <strong>Next<\/strong>. On the <strong>Choose color theme and data visualization<\/strong> page you will set the color properties and link the colors to a field in the data. In the <strong>Field to visualize<\/strong>, select <strong>SUM(<\/strong><strong>[<\/strong><strong>Amt<\/strong><strong>])<\/strong>. The <strong>Color<\/strong> rule is set so that smaller values are green and larger values are red, the opposite of what you need to see. Switch the order to <strong>Red-Yellow-Green<\/strong>. Click <strong>Finish<\/strong> and preview the report. It should look like Figure 22. <\/p>\n<p class=\"illustration\"> \t<img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/2105-1-e2928d2d-45bf-4237-9bbe-4718952ca26d.png\" alt=\"2105-1-e2928d2d-45bf-4237-9bbe-4718952ca\" \/><\/p>\n<p class=\"caption\"> \tFigure 22 <\/p>\n<h1>Wrap up<\/h1>\n<p> \tI hope this article has given you some insight into the visual controls. Between the visual controls&#8217; rich features and SSRS&#8217;s ability to set nearly every property with an expression, you can see that Microsoft has delivered an extremely powerful and user-friendly set of visual features in this reporting tool. <\/p>\n<p> \tStay tuned for Part 4 of this article series, which will peel back the layers on RDL (Report Definition Language) and take a look at Report Builder. <\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>The challenge of report development is to present complex data in a simple, visually compelling way. The goal is to make it as quick and easy as possible for others in the organization to use that data to make decisions, to see progress towards a business target, or spot and act on worrying trends sooner rather than later. Kathi Kellenberger demonstrates how to start adding visual flair to your SSRS reports, using its impressive set of visual controls, ranging from basic charts to gauges, indicators, sparklines, and maps.&hellip;<\/p>\n","protected":false},"author":110218,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[143528],"tags":[4242,5983,5982,5753,4379,4179,5984,4150,4151,4400],"coauthors":[],"class_list":["post-1916","post","type-post","status-publish","format-standard","hentry","category-bi-sql-server","tag-basics","tag-charts","tag-graphs","tag-maps","tag-reporting-services","tag-source-control","tag-sparklines","tag-sql","tag-sql-server","tag-ssrs"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/1916","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/110218"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=1916"}],"version-history":[{"count":4,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/1916\/revisions"}],"predecessor-version":[{"id":91014,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/1916\/revisions\/91014"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=1916"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=1916"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=1916"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=1916"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}