Calculate Min and Max for aggregation in SSRS report - reporting-services

My SSRS report have a dataset that will return the following result. The result set for some reason may not be changed. Note that Category - SubCategory pair might not be distinct.
Category Sub-Category Value
-----------------------------
A A1 100
A A2 120
A A2 60
B B1 80
B B2 90
B B2 70
I want to show the max value and main value for each of the SUM(category, subCategory) in report matrix, as exactly the format as follows (except the comment in bracket):
Max | 180 (two A-A2 rows)
Min | 80 (B-B1)
How can I define the matrix and write the expression? If make a group on these two columns, The matrix will show four rows regardless of what expression I set.

I tried to run your use case on my local SSRS.
On Left hand side I have original Data and on Right hand side I have the desired result you expect.
What you need is grouping as below
Expression for sum as below

Put a tablix into your report. Then at Row Groups (bottom) click on the (Details) and chose Add Group > Parent Group. Click the Add group header and chose your Sub-Category. Do the same with your Category. Your Row Grouping hierarchy should be now Category > Sub-Category > Details.
Now you see the brackets on the left in your tablix, they indicate the level. If you use now the following expression with their group name on the specific level, you will get what you want.
'At the Category group level header
=Sum(Fields!Value, "CategoryGroupName")
'At the Sub-Category group level header
=Sum(Fields!Value, "SubCategoryGroupName")

I got the way to make it. The solution is as follows:
Make a row parent group called row. Let the group group by a constant.
Make a child group category under the row group which is grouped by Category.
In matrix cell which is inside the group, Add this expression: =Min(Sum(Fields!Value.value), "Category"), "row"). that's the reason why I make a constant group, because I want to make the nested aggregate function legal.
This expression will return all values identical within the Category group. Now add another row outside of these row groups. Pick a cell and enter =ReportItems!ThatTextBox.Value.
Hide the row which consists your groups.
Do the same for MAX value (Start from adding an adjacent group, grouping by constant)

Related

SSRS Report - Badges

Is there an easy way to do a page of badges in an SSRS report? I am looking at 2 across and 3 down per page based on a list. I have built one so far of a single column using a list box but the problem is that it is not advancing to the next record and shows me the same record over and over until I get to the end of the count of total records in the dataset so I know I am doing something wrong. I am using Visual Studio 2017
I use a matrix when I am making a grid with boxes that go across and down.
First I add a ROW_NUMBER to the query to have the order in which to show the records. I subtract 1 so the values start with 0.
SELECT *, ROW_NUMBER()OVER(ORDER BY EFF_DATE) - 1 ROW_NUM
FROM BLAH_BLAH...
Then in SSRS, add 2 Calculated Fields to the dataset with the ROW_NUM.
The first is named ROW. It will have an integer with the row that the record will end up in.
=INT(Fields!ROW_NUM.Value / 2)
The second is COLUMN that will give the a column number.
=Fields!ROW_NUM.Value MOD 2
Then in the matrix, set the grouping based on the calculated fields.
COLUMN GROUP
Group and Sort by COLUMN
ROW GROUP
Group and Sort by ROW
The 2 can be changed to use whatever number of columns is needed.

SSRS, return rows into a grid layout

I have a dataset that I need to arrange into a grid on a page (export to pdfs) as a customer report. Each row in my dataset needs to display as a cell. Each page would have roughly 3 records displayed as columns and then 4 rows of records. e.g. a (3x4 grid), being 12 records per page.
Right now I am using a matrix to display my results, but I cannot find how to get my matrix to start a 2nd row after 3 columns are generated.
Is this feasible or should I find a different solution to create these reports?
I was thinking may be if I had row groups to use, but not sure how to create a column that creates a repeating result 3 times then adds 1 to the next 3 results in my query. 111,222,333,444 and that could be my row grouping?
Here's what I use in a matrix to create a grid of columns from a single cell.
Add a ROW_NUMBER field to the dataset query and subtract 1 with the ORDER BY using the field to be ordered by.
ROW_NUMBER()OVER(ORDER BY DISPLAY_NAME) - 1 AS ROW_NUM
Add Calculated Fields to the dataset using the ROW_NUM.
Call the first COLUMN and MOD row_num by 3 to get values or 0 - 2 for the column number:
=Fields!ROW_NUM.Value MOD 3
Call the second calculated field ROW and get the INT of ROW_NUM divided by 3 to get the row number for the record:
=INT(Fields!ROW_NUM.Value / 3)
Then the matrix would have the Column grouping (and sorting) based on the COLUMN field and the Row grouping on the ROW field.
You could use a parameter as the number of columns (3) to make it easy to change.

SSRS Grouping specific rows

Wondering if it is possible to only group specific rows in a tablix as when I add a child group it groups all 3 row of my tablix and I need it to only group the bottom 2.
The tablix does not have a header and I need the top row to be grouped on 2 fields and the next 2 rows to be grouped with the above as well as several other fields
Am I just missing something completely obvious or can this just not be done
This cant be done like you descripe it. But you can use a workaround. You need to mark the rows you dont want to group with a indicator (this can be done in a calculated field) Indicator = {0, 1}. Then you group like you descriped it. The grouping should now look like this:
Value Indicator
1 0 '1st row of group
12 1 '2nd row of group
33 1 '3rd row of group
Now you add a filter to your tablix where you exclude all rows where the indicator value is 0. Then it would look like this:
Value Indicator
12 1 '1st row of group
33 1 '2nd row of group
Of course your indicator needs a expression which identifies the first row per group.

How to create a parent group totals based on different child group

I'm not sure if I'm phrasing this correctly...
I need help splitting a total to have multi-rows/columns inside a total;
or another way to say this is, I need to have a parent group total with based on different child group.
Please see the picture below:
I am using matrix element for my stepped report. I have 4 tiers of groups on the Y-axis, and 3 tiers of groups on X-axis. On the y-axis, I have created totals for my tier 2 - Products (Linked/non-par) and totals for my tier 3 - products (A / B).
However, for the tier 3 - products (A / B) total, I need to split that total into total-A and total-B, so that the accumulative total values (66800) would be split into the sum of product A and sum of products B.
I'd like to do this without using expressions if possible. But if there are no solution, I'm open to Expression or changing dataset w/ T-SQL (if necessary).
Any ideas?!

Grand totals in Telerik Reporting

I'm trying to put together what I had thought would be a fairly simple report using Telerik Reporting, and I'm having a problem.
The data source is a DataTable containing outergroupid, innergroupid, number1, and number2, sorted by outergroupid, innergroupid.
I want a report laid out like this:
Outer Group 1
Inner Group 1.1 12 14
Inner Group 1.2 11 17
Outer Group 1 Totals: 23 31
Outer Group 2
Inner Group 2.1 22 24
Inner Group 2.2 21 37
Outer Group 2 Totals: 43 61
Totals: 66 92
And all of this is pretty easy, except the final grand total.
I created a group on outergroupid, and added a header with the id, and a footer with id, "Totals:", and Sum() on the numeric fields, and that handled the subtotals fine.
My problem: if I add a grand totals line in the report footer, I get a page break between the detail and the report footer - which I can't have. I've fiddled with KeepTogether, and it doesn't seem to have made a difference.
My next try was to create a global group within the detail. I'd figured that if I introduced a group with no grouping expression, it's GroupFooter would process after everything. It didn't.
So, what I need is either a way to keep the report footer from breaking onto another page, or a way to create a group that groups on everything.
Any ideas?
Solution 1 (on a 'traditional' report): add a fake group on top the real group. With a condition e.g. like "1=1".
Note: do not use the footer for this.
Solution 2: use a table item (a.k.a crosstab). On a table item, you can easily have totals and grandtotals.
The table item (with its details, totals and grandtotals) will be on the same report's section. E.g. on the report's Detail section.
You must create a report to have 2 grouping ,first you already have , A second is group that upper level than your current group,and then that group you must set data for grouping(fake data column from Databse ) at whole report , at last on report set show group footer then set content you want to.
For easy designing you can use a table object or it applies to normal report too.
Add a row group on the detail section and then add a parent row group of the 1st group by allowing the wizard (if comes any) to add their header and footer rows.
Now after all rows (in detail section) add a new row (for grand total). Any aggregated value added in this new row shall a grand total and will be shown on the same page.