Search code examples
sql-serverreporting-servicesreportingssrs-2014

How to make multiple group in 1 row in SQL Server Reporting Services - SSRS


I have created a report to show some data, but I need to get the sum for each group field value. But so far, I can only make a total for one field. From the sample table below, I can only make sums based on UOM or base UOM. I can't do it for both. List of UOM and Base UOM may vary depends on data. Is it possible to make it like the result below?

Stock Date Product Code Product Name Qty UOM Base Qty Base UOM
12-May-23 P002142213 Product A 150 PC 150 PC
15-May-23 P032142432 Product B 200 PC 200 PC
18-May-23 P947289323 Product C 160 CB 80 BAL
21-May-23 P012412323 Product D 250 CB 250 CB
24-May-23 P123412332 Product E 100 PC 100 PC
27-May-23 P124213232 Product F 260 CB 260 CB
Total 570 CB 80 BAL
450 PC 510 CB
450 PC

Solution

  • This answer uses tables within merged cells to achieve a result that is very close to your requirements.

    I started by reproducing your data then added a simple table showing the data.

    I then added a few rows outside the current details group so the rows always appear below the main data.

    The first new row is just so we can control the gap between the detail and summary data.

    On the second new row I then merged the Qty and UOM columns and made the row height bigger (double normal height).

    I then inserted a table into this merged cell. Inside thsi table I set the row grouping and sort both to the UOM field and =SUM(Fields!Qty.Value) as the value expression.

    I then repeated this process for the Base qty and Base UOM columns.

    I then cleaned up the formatting by removing borders from the new rows.

    The final result looks like this...

    enter image description here

    Here's a short GIF to show the process. (Right-click and open in new window to watch it maximised).

    NOTE: I didn't realise the crucial part was chopped off the bottom of the recording. When I right-click the merged cell I do "Insert ==> Table"

    enter image description here