I have a report in SSRS which basically contains a table of dates and blank columns for users to print and then manually write data into.
The report has a #FromDate and a #ToDate parameter as well as a #Location parameter.
The #FromDate and #ToDate parameters are used to populate a table with dates and is grouped per week (Mon to Sun) with a few extra columns that are blank for manually writing data. Above this table there is a textbox containing employee name.
What I am trying to do is to get the employee name to change for every page according to the #Location parameter. So if a location has 10 employees I need 10 pages with the different employees names at the top so 1 page per employee. The main table with the dates should repeat but the data will be exact on each page, basically the only thing that will be changing is the employee name at the top of the report.
Currently I have tried creating a table with just a header and adding the employeename field into the header but it only returns the 1st employee within the dataset and only returns 1 page when there should be 26.
What would be the best way to achieve this? It seems simple enough in theory but can't get it to do what I need.
A rough outline:
Create a subreport that shows your calendar. It will take the two date parameters.
Create a parent report.
The dataset in the parent should return a list of Employees for the selected location.
Create a table for that dataset, and put two detail rows in that table. The first will just have Employee name.
Test at this point and see that you just get a list of employees.
Place your subreport in the second detail row, and set the parameters to be handed through.
Change the properties of the detail group to have a page break between instances.
If you let us know what isn't working for you, we can give more specific advice.
Related
I am creating a report in SSRS to show evaluation scores. It has three sections, and I need to link them all together on the PreceptorID field (2108 in this case). The top two sections are from the same query. I am filtering the results in each one to separate the counts because they have different column names. The third section is a subreport showing comments from evaluators. It also has the PreceptorID field in the data but is not displaying it. It has two parameters that should be populated by the main report query, but that does not appear to be happening. The report is returning all comments instead of only the ones with the matching PreceptorID.
This first image is from Crystal Reports showing how the finished product should look.
This is what I am getting from SSRS. It is showing counts for multiple people at the top. The counts in the middle are actually correct. They are all for the one person. The next person's counts are on the next page. The comments at the bottom are also not filtering on the one PreceptorID.
This image showing the subreport parameter that should be linking it back to the main query.
How can I tell all three sections to only return data for the same person on one page, and another person on the next page?
I would redesign the report structure slightly. This is only my personal preference, there are several ways to achieve this but I find this way easier to manage and maintain.
You'll need two subreports and a master report.
You already have the 2nd subreport so no extra work required there.
I would take you current report, strip out the link to the current subreport and change it so it only processes a single person (just like your existing sub report).
So SubReport1 will have the two tables from your current main report only. It will only accept a single person as a parameter (or pair of parameters in your case)
SubReport2 will be your current subreport. Again it only accepts a single person.
Next create a new report. This will be the master report.
Add a dataset that contains just enough info for list of people you want to report over. So the dataset query might be as simple as
SELECT PreceptorID, ClerkshipID FROM myTable ORDER BY PreceptorID
Add a table to this report and set it's dataset property to the dataset you just created.
Change the default (details) row group to group and order by whatever makes each record unique (maybe both the two columns listed above, may only one will be required, only you will know this).
Right-Click on the row header to the left of your table and do "Insert Row => Inside Group Below".
Remove all but one column
You should now have a table with 2 rows per group.
Right click the top cell in the group and do "Insert => Subreport", go to the subreport properties and point this to SubReport1 (or whatever you called it) and set the parameters has you have done previously.
Repeat this for second row, this time pointing to your second subreport.
In the row group properties, set page breaks to "Between each instance"
That should be it. This was done from memory so might not be 100% but based on the info in your question you should be able to work it out from here.
Things to check if this is not working
Open each subreport and test it by passing in parameters manually. Each subreport should only be returning data for a single person.
The master report should have a dataset that returns each person once i.e. if there are 10 people in total this dataset should only contain 10 rows.
The table in the master report should contain only two rows
Both rows must be EITHER within the same row group, or, if you have no other row groups, they will both be in the detail row group.
The report design should look something like this if you have a row group by person
or like this if you only have detail rows.
Finally, make sure the parameters you pass to your subreports are the Field values from your master report's dataset, NOT your master reports parameters.
I need to develop report at SSRS include pie chart, that based on dataset (the dataset can change every day)
Can I make "dynamic pie" on report that change the number of graphs according to the dataset I define?
[A particular day can have 2 employees (2 pie graphs) and another day can have 5 or more employees (and therefore need 5 different graphs)]
For example:
This is the report that I need, based on this dataset
Requested report
My_Dataset
Thank!!
Yes, this is a brief overview of the main steps...
You will need two reports.
The first will be a subreport. So build a report that takes one or more parameters, based on your sample data the parameter would be Emp_Name. Build this report that it can handle a single employee only. The dataset might be something like SELECT * FROM myTable WHERE Emp_Name = #Emp_Name
Once that is complete, create a second report. Add a dataset that contains just a list of the employees so something like SELECT DISTINCT Emp_name FROM myTable ORDER BY Emp_Name
Add a list or table to this report and set the dataset to the dataset you just created. In the list (or table) right-click inside the cell and "insert => Subreport". Set the subreport to be the first report you created. and the parameter to be the EMp_Name field from your dataset.
When you run the seconds report it will create one row in the list for each employee in the dataset, inside each row it will run your subreport and pass the respective paramater.
That's it really.
Note that this will produce a vertical list but it should get you started. There are plenty of examples of how to arrange horizontally.
I have a report which uses 3 datasets and on the report a am using Multiple Tables and Textboxes and expressions. When I run the report I have to select a Parameter which in this example is 'City'.
I want a new page for each City (parameter) , I have read to use page breaks and grouping but I selected a List from the toolbox and put that on top of my report, selected 2 'Cities' and expected it to return 2 pages but it returned 49 pages (majority blank)
I want a separate page per city how can I achieve this?
Thanks
If I understand you correctly (it difficult to be sure if you don't post your current design) then you would be better using subreports.
I'm assuming Cities are in a table in your database and each have a unique ID. If you only have the names then you can use CityName inplace of CityID and it will still work.
Create a new report.
Create new dataset (say dsSelectedCities and the set dataset query to something like ...
SELECT CityID, CityName FROM myCitiesTable WHERE CityID IN (#CityParameter)
This will automatically generate a report parameter called #CityParameter. Set the available values etc just the way you did in your original report, so if you need to add another dataset for this then do so. In this example I've assumed labels will be CityName and Values will be CityID. Whatever goes into the Values is what will be passed to our subreport.
Now add a table to you report, it only needs to be one column wide and one row long so just remove any other rows and columns just make sure you leave the detail row and not the header.
Set the dataset for the table to be dsSelectedCities
Make this remaining cell with wide enough to accommodate your subreport (which will be the report you originally wrote).
In the cell, insert a subreport
Set the subreport properties to point to your original report and set the parameter to the CityID field.
This table will act as a loop, for each record found in dsSelectedCities it will give us one row. As each row will have a single CityID we are passing that to the subreport, the subreport in turn just shows one City.
Set the page break option on the details group to break between instances.
You will probably have to modify your original report to accept a single CityID, it depends on how it was designed but hopefully this should get you going.
If this is unclear then post your current report design including all the details about parameters and I'll update the answer.
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 am modifying an existing report which is setup to let you view statistics per sales rep. You do this by changing the parameter sales rep in the report view.
I need to modify the report so that it can display a page for each sales rep. This will then be exported to Excel with each sales rep statistics being displayed in a separate tab.
I have researched this and found people talking about iterating over a report but I don't think that what they are referring too is what I am asking:
http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/27ffabcc-6286-4fed-a8bf-0e5d78560be3
http://jameskovacs.com/2005/08/04/digging-deep-into-reporting-services/
You can accomplish this several ways, so here is 1 suggestion
Create a new tablix report whose query returns a (unique) set of all sales reps
group by sales rep
there is no detail row, but in the group footer/header add a subreport
the subreport will be the report you already are using and it's parameter will be the sales_rep value from your main report query
set page breaks for the group
The main way I can think of doing it is to pass the parameters into the stored procedure, and in there have logic to UNION together all the possible results you want with a field for grouping the sections.
For example if they had a parameter for "Report Sections" and had selected "1, 2, 3", then you pass the parameter to the stored procedure; inside it uses a SplitString routine to convert the commas into a table format, and then constructing another temp table to hold the results. Everything is accumulated into there with a SectionNumber field (1, 2, 3, etc), and then the whole lot gets returned. Your group groups on that, with page break set, and that's it.