Interactive sorting in tablix with column and row groupings - reporting-services

I'm trying to define interactive sorting in a tablix. The sorting should affect the row order.
Attaching image of the tablix in order to explain what I'm trying to get:
I already tried to define the column header with interactive sorting and get SubjectParentID to be sorted by expression (the same expression as described bellow). The final setting I made is to apply the sorting to all groups in the tablix -
Attaching image:
The result wasn't current and the data got messed up in the cells.
Additional information: The columns are grouped by SubjectParentID. The rows are grouped by Username as parent and UserID as a child group.
The values are result of the following expression :
=iif(isNothing(Fields!ResReqCertID1.Value),
-99,
Sum(iif(Fields!CertStatusID.Value = 3
Or Fields!CertStatusID.Value = 4
Or Fields!CertStatusID.Value = 5,
1,
0)) - Fields!ResReqCertID1.Value)

In the Text Box Properties / Interactive Sorting window, change the Groups selection to the UserID group (assuming that is the most-detailed group providing the rows in your example).

This can't be done, interactive sorting cannot sort row groups by column values calculated within that group.
If you have 4 static columns you could hard code them. Then having no need for column groups interactive sorting should work as expected.
You could also define a static number, say 10, of dynamic columns, and use pivoting in the thebsql query to get columns 1-10 and their labels. Then set up 10 columns with interactive sorting on the Value_1 fields, and hide them if no data exist for that column. You could then also have an 11th column which also does column grouping but doesn't do sort if there's any chance you'll ever exc3ed the 10 columns.
You could also do this: https://www.c-sharpcorner.com/article/ssrs-interactive-sorting-on-matrix-column-group/ which is somehow even more complicated than my two solutions.
But yeah, you basically can't do this. SSRS cannot be told to sort row groups on values calculated from within the context of the column group that contained the copy of text box in which the sort button was clicked.

Related

SSRS - How to create a sum (total) of an expression column?

After plenty of research, it seemd I can't find a well-explained solution to my problem. I'll join some screenshots of my Tablix, group rows, and group columns to help you to understand.
First of all, here's my tablix. It's linked to a SharePoint List.
The expressions are all like this :
=Count(Fields!ID.Value, "NameOfTheGroup")
It counts the number of elements that are filtered by one of the group chosen in the expression, and it works perfectly fine at this point.
Now, here's my groups :
They all contains filters tomanage the count precisely to the need.
What I want to do : In the last row, I want to display the sum of each column that is in a group row. But theses rows aren't datasets fields, they are just only expressions, and I can't find a way to create a proper total of each column. I heard of Running Value but the few solutions I found about it didn't work.
Thanks for the future help.
EDIT: Actually, the problem seems to be much more complex: any rows I create under my group rows are invisible : if I create a new row under the "Classification", outside the "Classification" row group, the expression I insert in the "CDI", "CDD", etc... columns stay blank. I tried with various expression or just values like "Hello World".

SSRS - Merging cells of specific columns

I am developing a complex report in SSRS which should like below
Screenshot 1
output returned by stored proc have multiple rows of one User ID and based on that columns "Successful Orders -- Online - Total Orders", "Successful Orders -- Online - Total Amount" & likewise Retail - Total, Other - Total columns cells should be merged based on respective User Id.
I have used tablix control and tried adding grouping over columns which needs to be merged but it is not working as expected. in order to group I am setting Sum of returned Value in cell but yet no luck.
Can you please provide me some pointers in order to achieve whats expected. please let me know if you need more information
output after adding nested tablix
ScreenShot 2
also, distorted output with inner tablix. borders are causing issues
ScreenShot 3
Try placing a tablix in the cells containing the multiple rows to display them. Basically, you need to switch your approach from "How do I merge these cells?" to "How do I split these cells." Set up your grouping at the level you want your totals and then in each of the columns where you want the details displayed, add a tablix to display the details. You'll need to play with the grouping a bit to get it display correctly.
More details:
The sample you provided above should be one group level row, not multiple detail level rows. Add your group to that Tablix and the summaries you want for your Total columns. Then Merge each of the "Mode" and "Count" column pairs and insert a Tablix into that merged cell with the same grouping as the row with the Totals, but with only the Details row displayed (don't add group header or footer and delete the blank row and summary column that automatically gets added). Now just set your field values for Mode and Count and adjust your column widths to match the headings.
Here's a REALLY simple report that displays a Plant and the employees associated with that plant. This is the top level where you Totals group would go. The next image is the "inner" part, where you would add in another Tablix with the same group(s), but only the details displayed.
This is super simple example and you may need to include additional levels of grouping to match your report, but the fundamentals still the same - an "outer" Tablix with an "inner" Tablix with matching group(s).
There's a lot you can do with this approach by manipulating the groups, hiding/displaying different groups or even hiding the details and displaying subtotals.

add variable number of empty columns to a tablix

I have a tablix with a column group so that it will create a column for that field provided any row has data for that column.
I need to create a version of this report that contains some empty columns on the end.
I want the number of columns to be added to be based on some factor of the non empty columns with some min/max constraints also. (my question is not how to get the number of columns required)
so far i've tried.
1 - adding individual empty columns to the tablix and setting the visibility condition on each column.
a bit long winded and a bit of a faff.
2 - creating another column group and grouping on the same field, this creates
cant vary the number of columns returned.
am i missing a simple way of adding x empty rows or columns to a tablix? where x can be calculated somehow from the values in the dataset.
You will have to fib this scenario in your data. The column-wise grouping works with known data including those falling in the column group value with null values. There is no way to grow your groups without data unless you add some column group footer logic that would be pretty weird.
I would look into producing phantom NULL value records that will push out your columns.

SSRS Exclude hidden row values from total

I have a column called "Total" in SQL reporting service report.
When generating report I'm hiding some rows accoring to some formula,
But calculating the total that hidden rows values also calculating.
Can I know how to exclude hidden row value from total value?
You have two options:
Apply the same show/hide logic that you're using to hide rows to the aggregate expression.
Apply a filter at the table level.
To give an example, say I have some simple data and an associated table:
Now, say we want to hide all rows with negative values - we can do this by setting the row Hidden property as:
=IIf(Fields!val.Value > 0, False, True)
Which removes the row but doesn't change the total, i.e. what you're seeing:
We need to apply the same show/hide logic to the Sum expression:
=Sum(IIf(Fields!val.Value > 0, Fields!val.Value, Nothing))
Now the total looks better:
Taking a step back, if you want to hide rows and change totals, why not just apply a filter; in the above example this would be:
Which gives identical results without needing any show/hide logic at the row or total level.
Depending on the complexity of the expression this last option might not be applicable, but seems a bit neater to me if possible.

Exclude hidden table row from total

I've created a table with a group filter so some values stay hidden.
However, the row that shows the sum() of the above values, still counts the filtered values.
Usually I would apply the filter to the query, but I'm also using this same dataset in other tables on the same report so that's not an option.
Am I missing something here, or is this a flaw in MS Reporting Services?
This appears to be a "feature" of SSRS, apparently because it calculates values in table headers and footers before rendering the detail section of a data table.
One way around this would be to add a derived Boolean column to your dataset (assuming your data source is SQL Server, using a CASE statement or similar) showing whether the row should be excluded from the table where the filter is required.
You can then change your table filter to check the indicator, and use a expression to carry out a conditional sum to aggregate the correct total. Something like
=SUM(Iif(Fields!ExcludeRow.Value = True,0,Fields!ValueToSum.Value))
It's more of a question than answer...
How to resolve this issue if you know whether the row is hidden or not ONLY at the Row Group level?
i.e. if you're filtering on the totals by this Row Group, i.e. you cannot have a field indicating if Row is excluded or not in a dataset.
ex: I have AR Aging report which has totals per months, patients. I need to filter out negative totals per patients (Patient row group), but I have column groups as well - per month, so my dataset cannot be per-patient granularity and therefore, the only place SSRS can decide whether to hide or show the row is on the Row Group level...
I had the same issue but I had too many column totals where to enter the Iif().
I resolved it by removing the filter from the group and putting the filter into the Tablix Properties dialog box (Select Tablix, Right-click the top left corner grey box and choose Tablixc Properties).