Sum/Running Total of Expression in a Group - reporting-services

I have been racking my brains all day trying to research and figure out how to sum an expression in a group in a tablix. Here is the basic setup:
I have a parent group called "Type", and within that is a child group called "CostCode". I am hiding the details group underneath CostCode because it has individual transactions I don't need to see. So the visible data on the tablix is aggregated in the group header. In the CostCode group, I have a column with an expression that calculates a Projection figure for each header line of CostCodes using a group variable within the CostCode group.
In the Type group footer, I just want to calculate the sum of those projected figures like a subtotal. However, the aggregation and the way I've done this is making it confusing to me. Does anyone know how to do this?
Attached is a picture example of what I have going on. Again, just trying to sum the Projection column of which the values are from an expression:

Related

SSRS show X amount of rows per group

I have a report that in which I have some grouping, I want to limit the maximum amount of rows per group to be 5.
For example: In a group of purchased items I want to show the last five purchased per category.
I've tried with Ceiling(RowNumber("GroupName")/5) as when doing page break after Nth row but I'm not quite getting the results I want. I tried in the filter group property setting the Top N but this doesn't work at all.
Is there a way at all to force RowNumber() function to equal a fix value?
I'm finding this harder than I thought it should be. I cannot modify the dataset, so I can't do this by query.
Any workaround or idea will be much appreciated
You may not be able to filter a tablix using the RowNumber function, but you can hide a row if its row number is (for example) greater than 5.
Use the *Row Visibility" properties to specify an expression like this:
=(RowNumber(Nothing) > 5)
To restart counting for every group, use the grouping name as the scope (instead of Nothing).

SSRS Report - Subgroup Totals

I have an SSRS report that is currently pulling a single dataset. This dataset contains records of inventory we have. Each record is a separate asset.
I want my report to group by a certain field, and then subgroup by certain criteria that are determined with a couple different fields. Basically there is one parent group, and three adjacent subgroups. My grouping functionality is working correctly, however I am finding it difficult to add totals to each of the adjacent subgroups. When I add a total, it is totaling the specific field within the scope of the entire dataset, instead of limiting the total to just that subgroup.
How can I add totals per field within subgroup?
EDIT: Added sample data and explanation:
You can ignore the function code field, that is what I am using to group on the parent group.
asset number,description,first year,acquisition cost,function code
190,random asset,2008,5000,100
193,random asset45,2008,56000,100
197,random asset26,2014,3000,100
191,random asset27,2014,7000,100
192,random asset36,2013,15000,100
I can't seem to attach screenshots, so here goes..
In the report you can see three subgroups; Assets, AssetAdditions, AssetDeletions. In the tablix, you can see where these groups are positioned. You can also see a row directly beneath the group that is supposed to total the subgroup at the end. However, for some reason the scope is only taking into account the entire dataset. I have tried to modify the expression in the Sum function [Sum(acq_cost), "Assets"], adding in the scope parameter but then it does not allow me to even run the report. It yells at me saying that "Assets" is an invalid scope.
The easiest way I have done this in 2012 VS is to have it return as part of the data set and have it sum up the value.
For instance if you have a quantity for inventory, and you have a subset where you only want the total quantity for that set, you add another column to your dataset called TotalSetQuantity and the subtotal field will have the expression =SUM(Fields!TotalSetQuantity.Value) rather than =SUM(Fields!Quantity.Value).
You can try iif statements within your report like =sum(iif(Fields!ColA.Value=1,Fields!Quantity.Value,0) but I had some troubles getting that to work.
Hope that helps, I ran into this issue this past week and the first option worked like a charm for me.

In SSRS, how do I compare a value of a parent report item with report items in a child group?

I am using SSRS 2008. I have 3 different groups above my report details that are calculated sums. I am trying to color the limit red if any of the invoice sums(A) in a child group is above the limit(B).
I am currently using this expression, but it is only looking at the first or last invoice amount. The limit report item is in a parent group just above the invoice's group.
=IIF(ReportItems!Invoice_DueDate.Value>ReportItems!Limit.Value,"Red","Black")
My Solution: I decided to use SQL to get the sum of the invoice amount grouped by due date. I then called that field in the parent group.
If I understand your question correctly, then I think you can use
=IIF(MAX(ReportItems!Invoice_DueDate.Value) > ReportItems!Limit.Value,"Red","Black")
You need some sort of aggregate function, such as MAX() to tell SSRS what the scope and operation of what should be done. (For example if you wanted to make sure the total didn't exceed the limit, you would use SUM(...)
You can reference parent groups from a child group using aggregate expressions specifying the parent group Scope.
For example, say we have some simple data:
And a simple table based on this, with a group based on grp.
Here the BackgroundColor property for the value textbox in the detail row is set as:
=IIf(Fields!value.Value > Min(Fields!limit.Value, "Group1")
, "Red"
, Nothing)
This checks all rows in the parent group of the current row, not just the current row. This works as expected:
Without knowing your data it's impossible to say if this will work in your case, but hopefully it gives you something to consider.
Edit after comments
OK, based on further comments it seems like you need aggregate on aggregate functionality.
This is available via SSRS expressions in 2008R2 and above only, so this won't help in your case.
For older versions, your best option might be to add an extra field to your Dataset that supplies the maximum Invoice value for each group, and then you can use this value without issues in the parent group.
There are some workarounds around that suggest using custom code to do this, such as this post, but I've never used this suggested solution and would only even consider it if you don't have any control over the report Dataset.

How to I get cumulative monthly subtotals in SSRS?

I'm using SSRS to create a report which shows a lot of transactions according to a trade date. I've made a group on the month and year called 'grpMonthYear'. Inside that group I've made a subgroup on 'TradeDate'.
The groups and all work perfectly. I'm also generating monthly subtotals in the footer of the group 'grpMonthYear'.
But now I want the cumulative subtotals.
Example, if Jan'13 totaled up to $5,000.00 and transactions in Feb'13 totaled up to $7,000.00 So the monthly subtotal in Feb'13 should show me $12,000.00
I tried using
RunningValue(Fieldname,SUM,'grpMonthYear')
But it doesn't work.
Am I missing out something?
You need to set the scope in the RunningValue function to one outside the current group, for example the table's DataSet itself.
So something like:
RunningValue(Fieldname,SUM,"DataSet")
Here's a simple example based on the following data:
I've created a simple report grouped by grpMonthYear:
The Month Total is just the sum in the current group scope.
The Cumulative Total expression is the following:
=RunningValue(Fields!tradePrice.Value, SUM , "Trades")
Where Trades is the DataSet name. This now gives the required results:
So hopefully this helps - just keep the ordering of all the elements of the table in mind as well as the specific parent scope to use if there are nested groups.

SSRS Grouping by value ranges: change scope when selecting value

Currently developing a report that groups items by value range. Using fictional data to describe the situation:
I'm trying to get this desired output, but I cannot use aggregate functions (Sum, Avg) when grouping items. Is there any way to group the ranges on the parent (order) level while retaining the child (order line) data? Any help would be appreciated.
Currently when I try to sum up the data, the sum of the order line is used (which is equal to the value and of no use to me).
I would do this at the dataset level. Either by using a separate dataset with Order Totals and the SSRS 2008R2 lookup function or by adding an Order Total column to the current dataset.
In these you could either get the group value ("1 to 10", "11 to 20"...) or the actual order total and create the grouping in the Group By formula in the SSRS group.