{"id":85295,"date":"2019-10-01T00:40:01","date_gmt":"2019-10-01T00:40:01","guid":{"rendered":"https:\/\/www.red-gate.com\/simple-talk\/?p=85295"},"modified":"2022-04-24T20:50:10","modified_gmt":"2022-04-24T20:50:10","slug":"reporting-services-basics-adding-groups-to-reports","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/bi-sql-server\/reporting-services-basics-adding-groups-to-reports\/","title":{"rendered":"Reporting Services Basics: Adding Groups to Reports"},"content":{"rendered":"<h4>The series so far:<\/h4>\n<ol>\n<li><a href=\"https:\/\/www.red-gate.com\/simple-talk\/sql\/bi\/reporting-services-basics-overview-and-installation\/\">Reporting Services Basics: Overview and Installation<\/a><\/li>\n<li><a href=\"https:\/\/www.red-gate.com\/simple-talk\/sql\/bi\/reporting-services-basics-creating-your-first-report\/\">Reporting Services Basics: Creating Your First Report<\/a><\/li>\n<li><a href=\"https:\/\/www.red-gate.com\/simple-talk\/sql\/bi\/reporting-services-basics-understanding-data-sources-and-datasets\/\">Reporting Services Basics: Data Sources and Datasets<\/a><\/li>\n<li><a href=\"https:\/\/www.red-gate.com\/simple-talk\/sql\/bi\/reporting-services-basics-parameters\/\">Reporting Services Basics: Parameters<\/a><\/li>\n<li><a href=\"https:\/\/www.red-gate.com\/simple-talk\/sql\/bi\/reporting-services-basics-adding-groups-to-reports\/\">Reporting Services Basics: Adding Groups to Reports<\/a><\/li>\n<\/ol>\n\n<p>So far in this series, I\u2019ve shown you how to create a basic report with parameters. The next necessary skill for report developers is to add grouping levels to the report. Managers often want to see subtotals, for example, at various levels, and adding groups is the way to do this. The report might be divided into categories and subcategories, maybe by locations and departments, or possibly by year and month. Whenever there is a hierarchical relationship in the data, it might make sense to add groups based on those relationships.<\/p>\n<p>There are several ways to add groups, but I\u2019m going to show you the ones that have worked the best for me.<\/p>\n<h2>The Groups section<\/h2>\n<p>When you look at a report in Visual Studio in design view, you will see a section under the report canvas with <em>Row Groups<\/em> and <em>Column Groups<\/em> as shown in Figure 1.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1438\" height=\"763\" class=\"wp-image-85296\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image.png\" \/><\/p>\n<p class=\"caption\">Figure 1: The groups section<\/p>\n<p>If you don\u2019t see the section, click on the report and then select <em>Report View Grouping<\/em> from the menu as shown in Figure 2 to make it visible.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"632\" height=\"307\" class=\"wp-image-85297\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-1.png\" \/><\/p>\n<p class=\"caption\">Figure 2: Where to turn on the Grouping section<\/p>\n<p>You may be wondering what the difference is between column and row groups, and they are quite different. Row groups are used to organize the report into horizontal sections in a typical report. Figure 3 shows one page of a report with row groups.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"651\" height=\"836\" class=\"wp-image-85298\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-2.png\" \/><\/p>\n<p class=\"caption\">Figure 3: A report with row groups<\/p>\n<p>Column groups are used in matrix reports, which might also be described as \u201cpivot\u201d reports. A matrix report displays data from a column across the top of the report as headings. You can also add row groups to matrix reports. For example, you might want to display several years across a report along with row groups for category and subcategory as shown in Figure 4.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"564\" height=\"728\" class=\"wp-image-85299\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-3.png\" \/><\/p>\n<p class=\"caption\">Figure 4: A matrix report<\/p>\n<p>The SSRS Toolbox contains <em>Table<\/em> and <em>Matrix<\/em> items. When you add either one to a report, you\u2019ll notice that each is called a <em>Tablix <\/em>instead of the original name. It\u2019s also possible to turn a <em>Table<\/em> into a <em>Matrix<\/em> by adding column groups or turn a <em>Matrix<\/em> into a <em>Table<\/em> by removing the column groups. In my experience, it is better to start with the one you need.<\/p>\n<p>For years, I used the SSRS wizard to create matrix reports, but eventually I realized that simple matrix reports were not that difficult.<\/p>\n<h2>Creating a matrix report<\/h2>\n<p>In this example, I\u2019ll show you how to create the report shown in Figure 4. If you need help with setting up an SSRS project or creating data sources or datasets, be sure to go back to the earlier articles in this series to learn more.<\/p>\n<p>To get started, you\u2019ll need an SSRS project with a shared data source pointing to the AdventureWorks2017 database. Create a new report by right-clicking <em>Reports<\/em> and selecting <em>Add New Item\u2026. <\/em> In the <em>Add New Item <\/em>dialog, select <em>Report<\/em>. Name the report <em>Sales by year and category<\/em> and click <em>Add<\/em>. The dialog will look similar to Figure 5.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1413\" height=\"806\" class=\"wp-image-85300\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-4.png\" \/><\/p>\n<p class=\"caption\">Figure 5: Creating a new report<\/p>\n<p>Inside the <em>Report Data<\/em> window, create a <em>Data Source<\/em> that points to the project\u2019s <em>Shared Data Source<\/em>. Create a <em>Dataset<\/em> that is embedded in the report named <em>ProductSales<\/em> with the query below:<\/p>\n<pre class=\"lang:tsql theme:ssms2012-simple-talk\">SELECT PC.Name AS Category,\r\n       PS.Name AS SubCategory,\r\n       P.Name AS ProductName,\r\n       P.ProductID,\r\n       YEAR(SOH.OrderDate) AS OrderYear,\r\n       SUM(SOD.OrderQty) AS Quantity,\r\n       SUM(SOD.LineTotal) AS SalesAmt\r\nFROM Production.Product AS P\r\n    JOIN Sales.SalesOrderDetail AS SOD\r\n        ON SOD.ProductID = P.ProductID\r\n    JOIN Sales.SalesOrderHeader AS SOH\r\n        ON SOH.SalesOrderID = SOD.SalesOrderID\r\n    JOIN Production.ProductSubcategory AS PS\r\n        ON PS.ProductSubcategoryID = P.ProductSubcategoryID\r\n    JOIN Production.ProductCategory AS PC\r\n        ON PC.ProductCategoryID = PS.ProductCategoryID\r\nGROUP BY YEAR(SOH.OrderDate),\r\n         PC.Name,\r\n         PS.Name,\r\n         P.Name,\r\n         P.ProductID;<\/pre>\n<p>After creating the dataset, the <em>Report Data<\/em> window should look like Figure 6.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"229\" height=\"341\" class=\"wp-image-85301\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-5.png\" \/><\/p>\n<p class=\"caption\">Figure 6: The Report Data window<\/p>\n<p>The next step is to drag a <em>Matrix<\/em> object to the report canvas from the <em>Toolbox<\/em> window. You can also right click the canvas and select <em>Insert Matrix<\/em>. The empty matrix object will look like Figure 7.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"364\" height=\"134\" class=\"wp-image-85302\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-6.png\" \/><\/p>\n<p class=\"caption\">Figure 7: The empty Matrix<\/p>\n<p>When creating a matrix report, the trick is figuring out what goes where. The <em>Columns<\/em> cell will contain the column you want displayed as headings across the report. The <em>Data<\/em> cell will contain the value you want to aggregate. The <em>Rows<\/em> cell will be the remaining columns. In this case, the report must display the years across the report and add up the sales amount.<\/p>\n<p>Drag <em>OrderYear<\/em> to the <em>Columns<\/em> cell, <em>SalesAmt<\/em> to the <em>Data<\/em> cell, and <em>Category<\/em> to the <em>Rows<\/em> cell as shown in Figure 8.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1148\" height=\"412\" class=\"wp-image-85303\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-7.png\" \/><\/p>\n<p class=\"caption\">Figure 8: Report after adding main items<\/p>\n<p>Notice that you can see the grouping levels in the grouping section. When you run the report, it will look something like Figure 9.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"773\" height=\"282\" class=\"wp-image-85304\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-8.png\" \/><\/p>\n<p class=\"caption\">Figure 9: The report so far<\/p>\n<p>The report\u2019s not pretty at this point, but it does display as expected with the years going across the top as headings. The original report also includes subcategories. Go back to design view and right click on the <em>Category<\/em> group in the <em>Row Groups<\/em> section. Click <em>Add Group Child Group\u2026 <\/em>as shown in Figure 10.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1348\" height=\"287\" class=\"wp-image-85305\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-9.png\" \/><\/p>\n<p class=\"caption\">Figure 10: Adding a Child Group<\/p>\n<p>This brings up the <em>Tablix group<\/em> dialog. Select <em>SubCategory<\/em> as shown in Figure 11.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"727\" height=\"359\" class=\"wp-image-85306\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-10.png\" \/><\/p>\n<p class=\"caption\">Figure 11: The Tablix group dialog<\/p>\n<p>After clicking OK, the report should now look like Figure 12.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1084\" height=\"291\" class=\"wp-image-85307\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-11.png\" \/><\/p>\n<p class=\"caption\">Figure 12: After adding SubCategory<\/p>\n<p>When previewing the report, the top of it should look like Figure 13.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"910\" height=\"655\" class=\"wp-image-85308\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-12.png\" \/><\/p>\n<p class=\"caption\">Figure 13: The report<\/p>\n<p>You can format your report or not as desired since this article is about grouping, but at this point, I have to add some formatting for my own sanity! In this case, I have bolded the top row and the first two columns. Everything should end up bolded except for the <em>Data<\/em> cell as shown in Figure 14.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"481\" height=\"107\" class=\"wp-image-85309\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-13.png\" \/><\/p>\n<p class=\"caption\">Figure 14: Bold everything except for the total<\/p>\n<p>I also formatted the <em>SalesAmt<\/em> in the <em>Data<\/em> cell to be <em>Currency<\/em> with a thousands separator and no decimal places and added a heading with the report name. The default margins are too wide for this report, so I also changed them in the <em>Report Properties<\/em> and made sure that everything in the report was pulled to the left. (To learn more about formatting, see the previous articles.)<\/p>\n<p>After the formatting is complete, the report looks like Figure 15.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"472\" height=\"355\" class=\"wp-image-85310\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-14.png\" \/><\/p>\n<p class=\"caption\">Figure 15: The formatted report<\/p>\n<p>The next step is to add some totals to the report. It is so easy to do when working with matrix reports! Right-click the <em>Data<\/em> cell that contains the summed <em>SalesAmt<\/em> and select <em>Add Total Row<\/em>. Repeat for <em>Add Total Column<\/em>. Figure 16 shows you where to find these.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"903\" height=\"608\" class=\"wp-image-85311\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-15.png\" \/><\/p>\n<p class=\"caption\">Figure 16: Adding totals<\/p>\n<p>Adding these two totals will leave your report canvas looking like Figure 17.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"701\" height=\"233\" class=\"wp-image-85312\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-16.png\" \/><\/p>\n<p class=\"caption\">Figure 17: After adding the row and column totals<\/p>\n<p>You might just guess the next step: adding a grand total in the empty cell. Hover over the cell until the column list appears and click it as shown in Figure 18. Select <em>SalesAmt<\/em> which will automatically sum.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"908\" height=\"444\" class=\"wp-image-85313\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-17.png\" \/><\/p>\n<p class=\"caption\">Figure 18: Adding SaleAmt to the empty cell for a grand total<\/p>\n<p>I also had to format that last cell since it didn\u2019t pick up the previous formatting. After running the report, the first page in <em>Print Layout<\/em> mode looks like Figure 19.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"564\" height=\"728\" class=\"wp-image-85314\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-18.png\" \/><\/p>\n<p class=\"caption\">Figure 19: The matrix report with totals in Print Layout mode<\/p>\n<p>Obviously, you can add colors, a footer, and more to make this report look nicer, but just getting the data displayed correctly was quite simple! There\u2019s one more thing that might be useful here. If you are in <em>Print Layout<\/em> mode and scroll, you\u2019ll see that the top headings do not carry over from page to page. (If you are seeing alternating blank pages, go back adjust the page margins and make sure that the report edge has been pulled to the left.) To get the headings to appear on the second and subsequent pages, go to the <em>Tablix<\/em> properties and change the <em>RepeatColumnHeaders<\/em> and <em>RepeatRowHeaders<\/em> to <em>True<\/em> as shown in Figure 20. Probably the easiest way to see the <em>Tablix<\/em> properties is by selecting it from the list in the <em>Properties<\/em> window.<\/p>\n<p>(Note that this method to repeat headings doesn\u2019t work on regular table reports, and I\u2019ll explain how to do that later in the article.)<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"452\" height=\"843\" class=\"wp-image-85315\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-19.png\" \/><\/p>\n<p class=\"caption\">Figure 20: The properties to get the matrix report headings to repeat<\/p>\n<p>Now that you have seen how to create a matrix report, it\u2019s time to learn how to create a regular row-grouped report.<\/p>\n<h2>Creating a table report<\/h2>\n<p>You saw a glimpse of row groups in the last section, but this time you will learn even more about row groups in reports as you create the report shown in Figure 1. To get started, create a new report in the project with the name <em>Product Sales<\/em>. It will also point to the project\u2019s shared data source. Create a dataset using the same query that was used in the matrix report. Add a <em>Table<\/em> control to the report canvas and fill in the <em>Data<\/em> row, also known as the <em>detail <\/em>group, as shown in Figure 21. The headings should fill in by themselves.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"112\" class=\"wp-image-85316\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-20.png\" \/><\/p>\n<p class=\"caption\">Figure 21: The table with the detail row fields<\/p>\n<p>The report is grouped by <em>Category Sub Category OrderYear<\/em>, so <em>OrderYear<\/em> is the first \u201cparent\u201d above the detail. In this type of report, I think it is easier to start at the detail and build out, but you can also go the other way. To add the group, right click the <em>Details<\/em> group in the <em>Row Groups<\/em> section. Select <em>Add Group Parent Group\u2026<\/em> as shown in Figure 22.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"923\" height=\"150\" class=\"wp-image-85317\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-21.png\" \/><\/p>\n<p class=\"caption\">Figure 22: Adding a parent group<\/p>\n<p>This will bring up the Tablix group dialog where you will select the group\u2019s field. Select <em>OrderYear<\/em> since it is the direct parent of the detail row. Also check <em>Add group footer<\/em>. This is where the subtotals will go. The dialog should look like Figure 23.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"727\" height=\"359\" class=\"wp-image-85318\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-22.png\" \/><\/p>\n<p class=\"caption\">Figure 23: The Tablix group dialog<\/p>\n<p>After you click <em>OK<\/em> to add the group, you\u2019ll see quite a few changes to the report canvas. The <em>Order Year<\/em> group has been added to the report and to the <em>Row Groups<\/em> section. Figure 24 shows the report canvas at this point.<\/p>\n<p class=\"caption\"><img loading=\"lazy\" decoding=\"async\" width=\"1078\" height=\"402\" class=\"wp-image-85319\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-23.png\" \/> Figure 24: The OrderYear group added to the report<\/p>\n<p>The next parent level is <em>SubCategory<\/em>. This time, I\u2019ll show you another way to add a group. Right-click on the <em>OrderYear<\/em> cell and select <em>Add Group Parent Group\u2026<\/em> as shown in Figure 25.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"489\" height=\"506\" class=\"wp-image-85320\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-24.png\" \/><\/p>\n<p class=\"caption\">Figure 25: Another way to add a parent group<\/p>\n<p>Add <em>SubCategory<\/em> as the new group and be sure to select <em>Add group footer<\/em>. Repeat the process to add <em>Category<\/em> using either method. Make sure to add the new group as a parent to <em>SubCategory<\/em>. Once all the groups are added, the report canvas should look like Figure 26.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"916\" height=\"467\" class=\"wp-image-85321\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-25.png\" \/><\/p>\n<p class=\"caption\">Figure 26: All the groups added to the report<\/p>\n<p>There are a lot of empty cells, and you can add totals to some of them. To figure out which grouping level a particular cell belongs to just select it. You\u2019ll see the grouping level light up in orange as shown in Figure 27.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1183\" height=\"335\" class=\"wp-image-85322\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-26.png\" \/><\/p>\n<p class=\"caption\">Figure 27: The grouping level lights up in orange<\/p>\n<p>To add subtotal for each level, fill in <em>SalesAmt<\/em> for each cell underneath the <em>SalesAmt<\/em> cell. You can also add subtotals for <em>Quantity<\/em>. They will automatically sum as shown in Figure 28.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1057\" height=\"226\" class=\"wp-image-85323\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-27.png\" \/><\/p>\n<p class=\"caption\">Figure 28: Adding subtotals<\/p>\n<p>You can also add a grand total to the report by right-clicking the bottommost <em>SalesAmt<\/em> cell and selecting <em>Add Total<\/em> as shown in Figure 29.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"901\" height=\"565\" class=\"wp-image-85324\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-28.png\" \/><\/p>\n<p class=\"caption\">Figure 29: Adding a grand total<\/p>\n<p>When adding a total in this way, it is automatically added to the next parent grouping level. In this case, <em>Category<\/em> is at the top, so the total is added to the report level. You can add a grand total for <em>Quantity<\/em>. In this case, just add <em>Quantity<\/em> to the cell. The report design should look like Figure 30.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"807\" height=\"224\" class=\"wp-image-85325\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-29.png\" \/><\/p>\n<p class=\"caption\">Figure 30: Adding grand totals<\/p>\n<p>Preview the report. The report should look something like Figure 31.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"553\" height=\"303\" class=\"wp-image-85326\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-30.png\" \/><\/p>\n<p class=\"caption\">Figure 31: The unformatted report<\/p>\n<p>There is quite a bit of formatting that should be done, but I\u2019ll leave it up to you to decide what to do except to be sure to modify the report\u2019s margins so that all the fields fit on one page. After formatting, my report looks like Figure 32.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"597\" height=\"501\" class=\"wp-image-85327\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-31.png\" \/><\/p>\n<p class=\"caption\">Figure 32: Report with some formatting<\/p>\n<p>If you take a close look, it\u2019s hard to tell what levels the total amounts refer to. To fix that, follow these steps. In the cell under <em>ProductName<\/em>, add this expression to the <em>Value <\/em>property:<\/p>\n<pre class=\"lang:tsql theme:ssms2012-simple-talk\">=\"Total for \" &amp; Fields!OrderYear.Value<\/pre>\n<p>Holding down the Shift key, select the two cells in row 4 and columns 4 and 5. Right-click and select <em>Merge Cells<\/em> as shown in Figure 33.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"792\" height=\"517\" class=\"wp-image-85328\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-32.png\" \/><\/p>\n<p class=\"caption\">Figure 33: Merging two cells<\/p>\n<p>Add this expression to the new larger cell:<\/p>\n<pre class=\"lang:tsql theme:ssms2012-simple-talk\">=\"Total for \" &amp; Fields!SubCategory.Value<\/pre>\n<p>Remove the word <em>Total<\/em> from the cell to the left. Merge the cells in row 5 and columns 4 and 5. Add this formula:<\/p>\n<pre class=\"lang:tsql theme:ssms2012-simple-talk\">=\"Total for \" &amp; Fields!Category.Value<\/pre>\n<p>Finally, merge the cells in the bottom row and columns 4 and 5. The cell should just say <em>Grand Total<\/em>. Delete the original word <em>Total<\/em> from several cells. The report design should look like Figure 34.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"747\" height=\"361\" class=\"wp-image-85329\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-33.png\" \/><\/p>\n<p class=\"caption\">Figure 34: The subtotals labeled<\/p>\n<p>I would like to move some of the labels more to the left, but I found that the <em>Merge<\/em> Cells option was not always available. If it is for you, then modify accordingly.<\/p>\n<p>The last thing to do to make this report more usable is to have the headings repeat on new pages. If you go into <em>Print Layout<\/em> mode and scroll to page 2, you will see that the top headings do not repeat. The <em>RepeatRowHeaders<\/em> property doesn\u2019t seem to do anything on regular table reports. There is a way to do this, though.<\/p>\n<p>On the grouping section at the bottom of the page, select <em>Advanced Mode<\/em> as shown in Figure 35.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"689\" height=\"217\" class=\"wp-image-85330\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-34.png\" \/><\/p>\n<p class=\"caption\">Figure 35: Turning on Advanced Mode<\/p>\n<p>Make sure this is checked which will add <em>Static<\/em> sections to the row and column groups as shown in Figure 36.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"630\" height=\"298\" class=\"wp-image-85331\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-35.png\" \/><\/p>\n<p class=\"caption\">Figure 36: The Static groups<\/p>\n<p>Working only on the row groups, select the first <em>Static<\/em> group and open the <em>Properties<\/em> window. Change the <em>RepeatOnNewPage<\/em> property to <em>True<\/em> as shown in Figure 37.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"940\" height=\"562\" class=\"wp-image-85332\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-36.png\" \/><\/p>\n<p class=\"caption\">Figure 37: The RepeatOnNewPage property<\/p>\n<p>Repeat the process for the next two <em>Static<\/em> groups. Now when you run the report and scroll to page 2, you\u2019ll see the top headings repeated. Figure 39 shows you page 2 of my report.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"651\" height=\"836\" class=\"wp-image-85333\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2019\/10\/word-image-37.png\" \/><\/p>\n<p class=\"caption\">Figure 39: The report with repeating row headings<\/p>\n<h2>Summary<\/h2>\n<p>This article introduced adding grouping by walking you through the creation of two simple reports. This article covered a lot of ground, but there is still so much to learn. In the next article, you\u2019ll learn more about adding expressions to reports to add even more functionality.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Most SSRS reports are organized into grouping levels where it\u2019s possible to add totals for each group.  In this article, Kathi Kellenberger continues her SSRS series by walking through how to create both a Matrix and Table report.  &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":[],"coauthors":[11292],"class_list":["post-85295","post","type-post","status-publish","format-standard","hentry","category-bi-sql-server"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/85295","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=85295"}],"version-history":[{"count":2,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/85295\/revisions"}],"predecessor-version":[{"id":85335,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/85295\/revisions\/85335"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=85295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=85295"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=85295"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=85295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}