SSRS Total by Type - reporting-services

I am new to SSRS. I have a report that goes like this
Type Amount
A 500
B 200
A 100
C 400
C 200
I want to convert this to a report like this
Type Total Amount
A 600
B 200
C 600
Basically get distinct Types on the left column and th totals for those types in the right column. Is there a way i can do that easily?
Thanks

Starting with you simple report which just lists the records in your DataSet:
Design:
Results:
Right click on (Details)in the Row Groups section and choose Add Group -> Parent Group:
Choose the field you want to group by (Type in our example) from the Group by: dropdown, choose to add either a group header or footer and click OK:
Your table will now look something like this:
You can delete the second column and the third row - or second row if you chose to add a group footer earlier - entirely (clicking OK when deleting the row and being prompted to delete the associated group), leaving a layout like this:
Now just click the field selector for the empty cell in the table and choose your Amount field:
or right click on the empty cell, choose Expression from the context menu and enter the following expression:
=Sum(Fields!Amount.Value)
either of which should result in the formula being placed into the cell:
Now run your report and you should get the expected result:
There's loads of places online with similar guides and resources which you can also consult:
MSDN Reporting Services Tutorial (Adding Grouping and Totals)
MS TechNet (Calculating Totals and Other Aggregates)
MSDN (Add a Total to a Group or Tablix Data Region)
There are also several other similar questions here on SO which you'll find if you just search for them.

Related

SSRS report to print labels from a roll

Does anyone have any experience of creating a report that will print labels that are on a roll?
I can see plenty of examples for a sheet of labels, but nothing with any great detail regarding a roll.
Would the best method be to set the report page up to have 1 column and then adjust the size of the page to be the size of the label?
There will be different info on each label, and a varying number of labels per print.
So basically set up the report to mirror the label size and then repeat pages depending on how many labels need printing?
You should just be able to set your report to have the same page size as your label then design the report as normal.
As for producing multiple labels, you can either
have a single dataset containing all the info you need for all labels and group by whatever makes each label unique (e.g. a label number). Then add a page break on the row group property to put a break between each, or ..
you could create a subreport that just handles a single label and then have a master report that with a table control with a single 'cell' and the subreport inside that cell. You would then pass the parameters to the subreport from the main dataset. I think you've seen a similar answer I posted about printing sheets of labels, if you follow that then it should get you most of the way there.
Option 1 is probably the simplest method...
Step-by-Step for option 1
In this example I've used the Microsoft sample database WideWorldImporters, just so I could get some names and addresses.
Step 1: Write your query to get your data. In my example I used the following..
SELECT top 10 o.OrderID, c.CustomerName, c.DeliveryAddressLine1, c.DeliveryAddressLine2, cty.CityName, c.DeliveryPostalCode
FROM [Sales].[Orders] o
JOIN Sales.Customers c on o.CustomerID = c.CustomerID
JOIN Application.Cities cty on c.DeliveryCityID = cty.CityID
ORDER BY OrderID
This just gives me the order number, company name and address.
Step 2: Create a new report. I'm using Visual Studio but the process is almost identical in Report Builder if you use that.
Create a new, blank report
Add a datasource and dataset containing your query from step 1
Select the 'body' and set the size property to your label size. I used 100mm, 40mm
Select the 'report' and set the PageSize property to the same values as above and the margins to 0
Step 3: Add a table to contain the data
Add the new table
Delete the header row
Delete the last column (I have a two column label in my example but obviously up to you)
Select the table (tablix) using the grey table handle (top left of the table) and then set the dataset property to the name of the dataset you created earlier
Add enough rows to contain all your data, in my case 6 in total
In the RowGroups panel under the main report design, right-click the details rowgroup and choose Add Group => Parent Group. Select OrderID as the field to group on and click OK
Remove the newly added column and if prompted choose 'remove column only'
Right-Click the (OrderID) Row group and go to Group properties, click Page Break and choose 'between'
Set each row to contain your data until you end up with something like....
Clean up the formatting and that should be it. One label per page and each page set to your label size.
You may need to adjust the layout slightly to adjust for margins etc but this should give you a good start.

SSRS group by multiple fields and groupings

I have a query that returns the following fields:
GrantCode
EmplID
EmployeeFullName
AssignedUnit
DaysOff
HourlyRate
CalendarEventStart
CalendarEventEnd
NumberOfHours
StatuteNumber
ViolationDescription
I want to have a stepped SSRS report that shows:
the calendar start time, end time and number of hours under the employee name info and then another grouping that shows the citations that were issued during the time period. I can't quite figure out how to get the SSRS groups set up to display in this manner.
I currently have all the data in a single query/data set but can separate it if that will make the reporting easier.
Any suggestions?
Thanks!
Leslie
Add a tablix to your report. Put in the tablix the fields Citation Number, Statue Number, Violation Description, Number of Citations. Then go to Row Groups > Add Group > Parent Group chose for group by the EmplID and check the Add group header, then hit OK.
Afterwards click on the most left column in your tablix and chose Insert Column > Inside Group - Right. Do this a few times and put in these colums the fields EmployeeFullName, Assigned Unit, HourlyRate, DaysOff, StartTime, EndTime.
Then go to your Row Groups and click on the drop down by (Details) and chose Group Properties > Visibilty and check Display can be toggled by this report item:. Here you have to chose the name of the textbox where the EmplID field is. Now the detail data get toggled by the EmplID.
If you want other data to display just add another column and put your fields or expressions in this column. A new column before the two dotted lines is on the group level and column after the two dotted lines are for the detail section.

Use Top n on category group in chart

I have a report showing a table showing details, it has about 380 rows.
I want to add a simple bar chart using the same dataset.
In the chart is one value and one group: value = sum(amount) and category group = description order by sum(amount).
This is working fine, but chart is showing about 120 bars, because of 120 distinct descriptions. I only want to display the top n.
Can this be done in reporting services itself or do I need to do this is a query?
I found the answer myself.
There is a filter operator 'Top N' which can be used. It seems the field used in expression doesn't matter.
However it seems Reporting services first performs the topN en than sort the remaining data. So I had to make a second dataset anyway.

In SSRS is there a way to make a Row Group expand based on parameter value?

I've got a table with 5 columns, the first 3 of which allow the user to drill down through the levels of detail. Each of these columns (Region, Country & Office) has an associated Parameter so the user can select the geographic region for their report. Each parameter allows the selection of multiple values.
If the user selects 1 Region, 1 Country and 1 Office it's not exactly ideal for them to then have to expand each selection. Is there an expression I can enter somewhere to state that if only 1 value is entered in a parameter then that data set will automatically show as expanded?
This is in SSRS 2008 R2 if that makes any difference.
In the Group Properties for the detail group you can enter an expression for the initial visibility. Right now you probably have that set to "Hide." The expression needs to return a Boolean and could be something like:
=Parameters!Country.Count <> 1
This will have SSRS hide those rows if more (or less) than one value are selected in the parameter Country
But I have seen some unexpected results with this: test thoroughly. In my experience, BIDS handles these better than SSRS itself, so just when you think you've got it all working, it fails miserably once deployed. (Reason number 14 to have a test folder on production SSRS.)

Display data in SSRS

I have two tables on the SSRS report which displays data depending on the results returned by a single dataset.
The second table displays a subset of data which is displayed on the first depending on some parameters.Now I would like to implement a functionality which displays "no rows" in the second table if the countrows=0 (subset returned from first table) and display the data(subset of data in the first table) if the countrows>0
How can I implement this?
There is a property on the table called "NoRows" that allows you to enter any text you want to show if there are no rows returned.
you can also use this solution:
for your dataset2 click the tablix and at the bottom you shall have Row groups. Click on each of the row groups. So if you have 1 child and 1 parent you will have to do this on both.
1) Right click group_child->group properties->filters and put the following expression "=IsNothing(Fields!Group_Child.Value)="True"" "; set it as boolean expression and 'value'='False' and you will have to do same for Group_parent1 thru n.
This will display NO rows if you have NO data for bottom dataset. If this is the same thing you want to do with Tablix 1 go for it.