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.
Related
I've got a monthly report that is generated from data recorded each day. At the bottom of the report I have Sum, Min, Max, and Avg for certain fields.
I need to be able to also get data from the last day of the previous month to display at the top of the report, but this data cannot be included in the Sum, Min, Max, and Avg.
I'm assuming that this means I must run 2 separate queries and am unsure of how to do to this properly. I'm also curious if it might just be easier to run VBA on report Open to subtract from the earliest day in the query results and display the data that way.
What is going to be the easiest method to achieve these results?
VBA would work, but I think this is a better case for a subreport.
In the design view of the report, you should have a subreport tool. Drag and drop that, then set your source to the other query results you wish to display.
I have a table field in which I want to calculate the price of an order. In that table I have a field where you choose what dishes did the client order. And I need to get the prices of those exact dishes from another table and then sum them up. I want to calculate in field SASK and take prices from table VALGIARASTIS. So what should the formula be?
For example in field dish I choose Balandeliai,Bulviniai blynai, Cepelinai formula should take those names and get prices of it from table VALGIARASTIS and sum them up.
Here's a screenshot for you to understand.
The solution will not be a formula. It will be a VBA function that receive an array from the multi-value combo box, uses it to build a filter for the data in the VALGIARASTIS table, and uses an aggregate query to SUM() the price values.
For the first part, you can refer to these links:
http://allenbrowne.com/ser-50.html
http://support.microsoft.com/kb/135546
Once you have the means to filter a recordset, you can run an SQL query on the results using the SUM() function to get your total. You can run a DAO cursor through the recordset and get your total that way, but SQL is better.
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.
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.
I have a report where I'm counting the number of records for a day. At the bottom, I have the total records for that time period. I'd like to display the average records for each day. An example:
alt text http://img337.imageshack.us/img337/7168/ssrsexampletable.png
I can accomplish this by aggregating the data by date in SQL then just doing the Average and Sum of the count from SQL, but that would complicate the report considerably as I'm doing other column filters for the types of tests performed. There seems to be a simple way to accomplish this that I'm missing. I can't do Average(Count(field)) in SSRS, unfortunately.
Is there something I'm missing, or is there really not a way to accomplish this simply?
I'm missing something here....
Surely you just want the avg function?
Why do you need to count?
RS knows the scope of what you are trying to average, so it knows what to divide the total by.