creating a subtotal based on multiple columns in ssrs report - reporting-services

I am working in SSRS 2008 R2 and need to create a subtotal in a report based on two columns. For example, I need to subtotal a spend amount based on Cost Center and Account Number. This seems like a simple enough requirement but I am at a standstill.
Sample data:
Business Segment Company Code Cost Center Account Ship Date Ship to Ship From Total Amount
Home Furnishing 1008 1234567890 11111 1/1/2013 Tailspin Contoso 123.45
Baby/Parenting 1536 2234567890 22222 12/31/2012 Bobs Bait Jims Tackle 543.21
Kitchen Appliances 2553 3234567890 33333 11/11/1999 Ajax Acme 1000.99
I need to provide a subtotal based on Company Code, Cost Center and Account.

Since you're grouping on multiple rows, just create groups for each of these rows, but only display totals in a header or footer for the lowest level group.
For example, I've created a simplified Dataset based on yours:
I've created a Tablix and added groups for Cost Center and Account Number. However, I only included a group footer row for the Account Number group. In this footer I've added the summed Total Amount for the Cost Center / Account Number combination. It looks something like this in the designer:
The end result looks like this; it's displaying each individual row in the Dataset plus totals for each Cost Center / Account Number combination:

Related

SSRS: Replicate 'Irregularly Formatted Report'

I have been asked to replicate a legacy Crystal Report using SSRS.
I have all the component data in SQL [SSMS].
The problem I have is that the Subtotals Rows have columns that do not match the columns in the Detail that the totals are derived from.
The Page Header is directly associated with the Subtotals ... but the columns in the Header/SubTotals do not match the columns in the Detail for each Group.
For example:
Patient's Preferred Language
Spanish EngLish Unspec Total
Clinic Name - Department Name.
ID1. Name1 Spanish
ID2. Name2. English
....
10 15 5 30
33.3. 50.0 16.6
In the above, very abbreviated example, the top two rows represent the Page Header. The next three rows are the Patient Detail rows - with a Header for each Clinic-Department Group.
The numbers in the final two rows correlate to the Spanish, English, Unspec & Total in the Page Header and are the Counts - and the % below the Counts.
In reality, there are 4 sets of Headers - each with 4 sub-categories ... and the Detail section has a couple more fields for each Patient [Eg. Address, Phone, Primary Care Physician ...].
I have the Detail Data as one SQL Output and the Totals/% as a separate SQL Output.
The two different Outputs are tied together by a concatenated key [Clinic Name, Department Name, Provider Name] which exists in both the SQL Outputs.
My question:
Can I display the Data in SSRS so that it looks like the data shown in my example? I want the Detail Rows to appear between the Header and the Sub Totals.
Is this possible?
I am thinking of the Headers & the associated Totals being the Main Report - and the Detail being a Sub Report - but I don't know if it is possible to put a sub report between the Header and Totals of the main report.
I'd appreciate any pointers/suggestions.

Report Builder 3.0: What is the correct value for the average of this field?

Not sure if this belongs in Mathematics SE so just let me know and I can move it.
I am building a report in Report Builder 3.0 and I need to show how much we used on average over the course of a month.
Which value makes more sense here? Taking the average of the averages (5.3%, shown in image) or taking those sums at the bottom of the table and finding the overage that way? In the 2nd case, the calculation would be variance divided by qty required x 100%, or 274,213.02/6,283,281.11 * 100% = 4.4%. The last 4 columns in the image are quantity required, quantity used, (quantity used - quantity required) or variance, and (quantity used - quantity required)/quantity required or overage.
Screenshot of report
The correct way to get the overall average is "across" at the bottom - take the average of the sums.
If you average the averages, you give every subgroup equal weighting which is incorrect (usually). If you have two divisions, one of which made an average 5% profit on $100K sales and another which made an average 1% profit on $100M sales, the smaller division will unfairly "pull up" the whole company.
Or, to use a sports analogy: when calculating a hitter's batting average, you don't take their previous BA, then average it with the latest game's performance. You total up all of their at-bats and hits, and average that.

Hide Control Key Group Value in SSRS

I have been using SSRS off and on since SQL Server 2008. There are a number of typical SSRS pitfalls and gotchas. One of these I need to go over with some one.
This should be pretty easy for an experienced SSRS resource / expert.
Let me explain the scenario
I have an Invoice Header and Detail. The header contains the Invoice number and InvID. The INVID is the link column for the Invoice detail or the FK in the Invoice detail. I guess that must be pretty obvious to all.
Now I need a simple report that displays Invoices and their items.
For some reasons I do not want to use the Invoice number to group the invoices in the report. I want to use the INVID.
But I want to hide the value of the INVID and display only the invoice number.
In other words the report should look something like follows
Invoice Number Date / Descriptio Qty Rate Tax Amount
11001 12/52016
Item No 1 10 10 2 102
Item No 2 20 10 2 202
So on and so forth....
I know this is very easy. Any inputs would be welcome...
Plus any good recommendations in terms of resources for refreshing my knowledge of SSRS
Regards
With SSRS you have the flexibility to set the grouping conditions independently of what is displayed in the table. As the others mentioned, add a Row Parent Group by INVID. The group properties should look like this:
The basic table layout should look something like this:
So the outer group will repeat for each individual, but display the invoice number. The inner group will repeat for each applicable item.
This should point you in the right direction. I'm not sure of a good resource to direct you to. For me, trial and error has been the most helpful.
All you need to do is bring InvId in in main dataset which you are using in main Tablix, on Tablix you can apply grouping on any field of dataset.

Add row data to total,without showing row values SSRS

I am relatively new to SSRS. This is a Dynamics CRM report. My scenario is that I have a 15 truck drivers. I have created a report that shows their number of trips and the miles driven. I can sum the miles and get the total number of miles for each driver.
What I want is just the driver name and the total number of miles driven.I am not sure how to get that calculation done in SSRS. Any help would be greatly appreciated.
Regards
SR
It will be straight forward if your dataset just returns the data you need - the driver name and the total numbers.
But if your dataset returns the detailed data, not totals, then you can just hide the detail row of the tablix: right click on the detail row header -> Row Visibility... -> select the "Hidden" radio button. With that, I'm assuming your report already has the grouping by Driver and shows the total miles.
Best regards,
~Alexey

Can't get rid of duplicates in an Access sub report

I'm having an issue with a report containing a subreport in Access 2007. Let me preface this by saying that I didn't create this database, it was already in place and I've just kinda been put in the position of taking it over, and I don't know too much about access.
Basically I need my report to pull my customer history and payment history, group them based on the phone number, display all history below, and finally being sorted by received date.
What is happening though is I'm getting duplicates of all payment info.
Here's currently what is being output:
555-1212
john smith
123 whatever dr
hometown, usa 90210
sold date received date amount agentname
1/1/2013 1/4/2013 50 jack
6/1/2012 6/6/2012 25 jim
sold date received date amount agentname
1/1/2013 1/4/2013 50 jack
6/1/2012 6/6/2012 25 jim
So as you can see, it is grouping the sales correctly on the phone number, as shown by the phone number, name, and address only being displayed once. However for each instance that the subreport pulls, it shows all the info again. I need only one set of sale information to display per customer.
I have two tables, two queries, and two reports doing all of this.
One table contains customer information, the other contains sale information.
The queries simply pull the needed info.
My main report has the phone number, name, and address inside the header section. This is set to group on phone number, and to keep the group together on one page.
My subreport contains all the sale info inside the detail section. This is set to sort by received date.
I've tried a ton of combinations of grouping, sorting, and moving the subreport in and out of the header and detail sections but to no avail. One way or another there's always duplicates and I can't figure out how to sort the whole shebang by received date when all is said and done. Any help would be greatly appreciated!
Create a phone number group section and move the top line with phone number, name, and address AND the sales information subreport inside this new group header. Then, minimize the detail section.
From your example, John Smith has two sales info records. Therefore, the sub report placed in the detail section will repeat twice for its two appearances in the main report. Recall any item in detail section will repeat for the number in the recordsource. Yet positioning items in a distinct group section will remove the duplication.