Calculate total by summing max numbers - reporting-services

I have a Matrix report that has two row groups and two column groups. There is column which has the calculation Max(Fields!AdjustedManning.Value) on the Row Group level as a subtotal. I want to add a total at the bottom which is outside of the row group to sum the subtotal numbers up. What expression can I use to do this? Effectively I'm looking to sum the max numbers
In the image the yellow box for design is where I need to put the expression and a preview of what I would expect it to calculate.
Design and Preview

You didn't show the rowgroup names so I'm guessing you have a rowgroup grouped by [WoLine] called Woline. Assuming this is correct then you should be able to use something like...
=SUM(MAX(Fields!AdjustedManning.Value, "WoLine"))
"WoLine" is the name of the rowgroup, you must include the quotes and it is case sensitive so adjust to suit your actual report.
What this does is get the MAX value within the "WoLine" rowgroup scope and then sum the results.

Related

Expression to calculate % in a report

I am building a report(report server project) using the Data Tools. I have a column Quantity it has a Total.
I need another column that calculate the share(%) of each line in the Quantity comparing to the Total.
The expression would be: Line_1_Share = Quantity_of_line_1/Total.
I tried =[Sum(Total/Quantity)] but it does not even accept as a valid expression.
If you right-click the textboxes that contain your working 'Quantity' and 'Total' values and look at the expressions you will see the correct format.
For exmaple your 'Quantity' expression might be something like
=Fields!Quantity.Value
or if it is in a grouped row it might be
=SUM(Fields!Quantity.Value)
your 'Total' expression might also be
=SUM(Fields!Quantity.Value)
When you use SUM() (or any similar aggregate) then the scope of the expression decides what is included in the sum. The scope can be a single row, a row group or an entire dataset. If you do not specify a scope then the position of the textbox determines the scope.
So, if you have a simple table with no grouping other than the total line and your dataset name is dataset1 then your expression would need to be
=Fields!Quantity.Value / SUM(Fields!Quantity.Value, "dataset1")
The above reads .... "For the current row, take the Quantity and divide is but the sum of all Quantities that are within the entire dataset called dataset1"
If this does not help, post your current report design including and row and/or column groups.

SSRS - add percentage of total?

I am just starting out in SSRS and have a dataset that looks like the below.
I have built this in a matrix table like so
I want to show what percentage each of the rows total is of the grand total, so for the attached image I would want to show what percentage 35 (counselling calls) is of 47 (total) and what percentage Legal calls (12) is of total (47)
I have tried =Fields!Calls.Value/sum(Fields!Calls.Value) but that just gives me 100% for both?
Would appreciate any help
You need to specify the scope of your SUM() expressions.
I'll briefly explain how scopes work and then get to the answer.
SSRS always evaluates an expression based on it's scope which is usually defined by the physical location of the expression within table/matrix. As you can see from your design all 4 textboxes show the same expression, [SUM(Calls}] which in fact is actually =SUM(Fields!Calls.Value). However they give different results because the scope of each is different. The first is in the category rowgroup and the month column group for example, the second one is in the category row group but in the total month group, and so on...
OK, now to the answer !
Assumming
your rowgroup is called 'CategoryGroup` (you will see the name in the rowgroup panel under the main designer)
your dataset is called DataSet1
You expression should be
=SUM(Fields!Calls.Value, "CategoryGroup") / SUM(Fields!Calls.Value, "DataSet1")
This basically reads..
Take the sum of the call column for all rows that are within the current CategoryRowgroup and divide by the sum of the call column across the whole dataset.
Notes
The scope names must be enclosed in quote and are case sensitive
The scope names must match either a row or column group, or a dataset name exactly.
the , "CategoryGroup" scope argument can probably be omitted as this should be the scope of the textbox anyway.

SSRS Matrix not sorting when set in both tablix and row group

I have a matrix, as in the picture below, which I have set to sort by the Total invoiced. Field is being returned from the Db as a number, I just formatted it as currency in the field (sorry it is a bit ugly with the names removed, but its live data). However as in the picture below , it is not sorting on the total invoiced. I have set it to sort by TotalInvoiced in both the row group properties and the Tablix properties, with no luck. Anyone know how to resolve this issue?
Sorting added on the administrator group for the Total invoiced column. Visit year sorted on itself, VistiMonth sorted on itself (month in numbers) to show progression.
Remove all the sorting that is based on TotalInvoiced, just so you have a clean starting point.
Now check that your VisitYear and VisitMonth are sorted as required.
Finally, set the first sort expression in the AdministratorName RowGroup to
=SUM(Fields!TotalInvoiced.Value)
Set the Sort direction as required.
That should give you what you want, AdministratorName will be sorted by the sum of the TotalInvoiced field for that AdministratorName.

SSRS percentage of a total with column groups

I apologize in advance if this is not enough info or if it is confusing (This is my first post to the forum and it's a little hard to explain what i'm trying to do). I have been researching this for a couple days now. This article comes really close to what I need, but this person did not have column groups, just a a single column with an output: SSRS percentage of a total.
Consider this layout and groups:
The idea is to provide the percentage of the total records per PrimaryPayor per Company and then break it out by Year-Month.
This expression:
=CountDistinct(Fields!ID.Value, "Primary_Payor") / CountDistinct(Fields!ID.Value, "Company")
Results in this output (The first image is my output, the second is the desired output):
As you can see, the percentages do NOT group by Year-Month, instead just provides the total percentage of IDs per Payor per Company and repeats it for every Year-Month column. How can I get the percent of Total IDs per payor, company, and month as it shows in the second result image?
After editing my question, I thought of something I hadn't tried.
If I just use =CountDistinct(Fields!ID.Value), this gives the total count for each payor, company, month, plus, I added a Total row.
Then, if I reference those textbox values (instead of trying to calculate the percentage on the fly) divided by the total row, I get my results. I just had to add a column inside of the column group. I should then be able to just Hide my "total" column and display only the percentages.
=ReportItems!Textbox50.Value / ReportItems!Textbox35.Value
Here is the output (with the total counts and then after hiding the "count" column):
Final Results
Try:
=CountDistinct(Fields!ID.Value) / CountDistinct(Fields!ID.Value, "Company")
I removed the Primary_Payor scope leaving the function calculate the count in the cell scope Primary_Payor and DOS_YrMo.
UPDATE:
=CountDistinct(Fields!ID.Value) / CountDistinct(Fields!ID.Value, "DOS_YrMo")
Let me know if this helps.

How can I sum "Expr" in bottom of the table in SSRS?

I'm doing such a thing;
=Sum(Fields!TOTAL.Value) - Sum(Fields!IND.Value)
In cells, so this is end up with expresion "<<'Expr'>>", that means I'm finding net worth price - discount for each saled products, after that I want to sum all of those product's sales on bottom, like
=Sum(Sum(Fields!TOTAL.Value) - Sum(Fields!IND.Value) )
Any chance for that? I also tried like;
=Sum(ReportItems!TOTALBOX.Value)
But not work either.
Edit;
I'm doing something like that but on final, I want to sum those values which "<>" created.
Thx.
Since your data is in a Column Group (by [DEFINITION_] - the 3 columns with the line above them) you can create a total column using the same formula. The Total will SUM all the different DEFINITION groups for each [NAME] group.
You can add a column Outside the group and create your total column with the same formula
=Sum(Fields!TOTAL.Value) - Sum(Fields!IND.Value)
If you created everything correctly (and you're lucky), SSRS might be able to create the Total for you by right clicking on the cell and Add Total.