SSRS Exclude hidden row values from total - reporting-services

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.

Related

SSRS custom code

I'm having an issue in my SSRS report. What I'm trying to accomplish is get a correct summary total for a particular group, on field ClaimNumber
How the particular formula works is based on other fields in the record, and on of those values being zero:
=iif(Fields!FieldA.Value=0,0,Fields!FieldA.Value-Fields!FieldB.Value-Fields!FieldC.Value)
So if FieldA is zero, the displayed value is 0, otherwise it displays FieldA-FieldB-FieldC.
This works fine for each individual lineitem, but the summary totals on the grouping on ClaimNumber are incorrect, as in some cases the FieldA value under that particular ClaimNumber is 0, sometimes not. So I'm having trouble summing on the ClaimNumber grouping total, as the summary does not know which records FieldA is 0, and which are not.
There must be an SSRS custom code formula that would work in this situation?
If you wrap a Sum function around your expression, or even around each individual column in the expression, it's only going to evaluate that once. In other words, this describes the issue you're having where it's not accounting for some of the rows having 0 in FieldA. One way to correct this is to make your expression a calculated field on your dataset. Then you can Aggregate the calculated field to get totals and subtotals. Since it is a calculated field, it will be evaluated row by row to get the correct total. So the good news is: no custom code!

Hide Multiple Columns in SSRS Matrix

I have a Matrix report with some columns that are grouped by Month and Year in the Column Group. Now, these columns are being toggled by the Month Column as the Visibility Property is set to hide but toggled by the Month Column. But when the report is rendered, the hidden columns come out as blank and this defeat the purpose of the report, as seen in the images below. How do I do away with the blank spaces or which is the best way to meet this requirement?
I'm assuming you tried to set the individual column visibility properties...
You actually need to set the group visibility of your EnglishMonthName group to be toggled by [CalendarYear]. This will not hide the column completely (as you would not have anything visible to click on to get it back again) but it will collapse the data down and aggregate at the year level.
What you have done to hide your columns is actually working.
If you look at that WIDTH of each of the month then you will see they are of the same width. So according to your query you have the months appearing regardless of the corresponding data for that month.
I would do in two way depending on how the users would like it.
If possible and for better performance, I would alter the SQL query and do one of the following:
1. The months for which there is no corresponding data - I would remove the month names (or ID) as well
2. Rather than returning NULLs I would return a valid value like 0 or 'N/A' this will how the month as well as what the data actually is
To do it in the matrix you will need to alter the visibility of the month row as suggested by Alan Schofield

SSRS Row visibility based on another row's visibility

My SSRS report has the requirement to filter the report based on a cashier's variance to balancing to 0. My variance is a calculation based on two different datasets and values within those data sets.
I've used some custom code in order to pull some of the data from a second data set and then I use ReportItems! expressions to calculate the variance with it all combined in one chart. The requirement is to only show those cashiers that are off balancing by more than +/-$10. I've tried to put the ReportItem! expression in the filter for the tablix, but the filters won't take a ReportItem! expression. My next thought was to just hide the rows that don't meet my criteria, but when I do this one of my toggled rows unhides itself because it's parent is hidden now based on my row visibility expression. Is it possible to hide all child rows of hidden rows? Ideally, I'd turn this into a parameter so that the end user can change the range of what data to look at.
Did you try hiding the Group instead of the rows? Usually if there's a child within a group that is hidden, the child will hide too...
I'm not sure why, but I had to put group visibility settings on it as well as the row where all the other row groups I only had to do the group.

Interactive sorting in tablix with column and row groupings

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.

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).