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.
Related
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:
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.
I have a SQL Server Reporting Services report that shows customer order data, but it's grouped as follows:
Store
Customer
Customer Order Items
So, each report is a grouping of stores, with a subgroup of customers per store, and then the items per customer. I'm trying to show aggregate sale and other information at each header record of the appropriate group in the report. Most of this is working well, but for each store header record, I want to show a count of the customers. I'm trying to use some variation and\or combination of RowCount, CountDistinct and other aggregate functions, but to no avail.
Can anyone help me determine how I essentially can get a "count" of customer groups to show at the Store level header? TIA!
CountDistinct on Customer should work fine - no need to specify scope if it's in the Store group header row.
I put a simple test together.
Data:
Report in designer:
Most important thing to note is the CountDistinct on Customer in the Store header row; this is just the expression used:
=CountDistinct(Fields!customer.Value)
End result, showing correct values:
Please let me know if I'm missing something.
Edit after comment:
Apologies in advance for how long this is getting.
The previous report did have row groups for Store and Customer, but I've modified this to make it more clear, hopefully. Still based on the same DataSet:
You can see there are three row groups, and each row in the report is actually a group header row belonging to one of those groups.
In the Store group header row I've kept that same CountDistinct expression. I've also added a CountRows() expression to show how many actual rows are available in each of the different groups.
Here you can see for Store1, CountRows is returning 4, i.e. there are four rows that we are aggregating in this scope, which is what we expect looking at the DataSet.
Similarly, when we apply =CountDistinct(Fields!customer.Value) in the Store scope we are considering these same 4 rows, and we see two distinct customers for Store1, which seems correct to me.
For Store2 we are considering 6 rows in total, which have three distinct customers. Again, just by applying =CountDistinct(Fields!customer.Value) we get correct value.
Hopefully this rejigged report helps clear things up. If I'm still not getting your requirements, can you please explain what numbers are wrong in my sample report based on my sample DataSet? That way I can adjust things easily on my side.
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.
I swear this shouldn't be that hard, but it's been a real struggle.
I have a query that returns a site name, an event date, and the count of events. I use it in a very nice chart to show events by day.
I now want a Tablix to show the sum of those count of events by site. That is, ignore the date and just sum the counts.
I know I can write another query to accomplish this, but I'd rather minimize the number of queries in this report. How can I use the existing query to create the Tablix that I want?
in the tablix, create your group/groups that you want to sum by, then add the sum of the field you're summing. If you exlude the date in the groups then it'll just sum by whatever you group by.