Issues with displaying 2 tables in SSRS in a single page - reporting-services

I have 2 tables: Table 1- Header with 10k records
Header table:
UID || Po_number || Invoice Num|| Total Amount
101 || 41235 || abcdef || 5000
102 || 45324 || xyzghi || 7500
Likewise i have 10k records in header table above
Line table:
UID || Po_number || Product || unit_qty || unit_price
101 || 41235 || pencil || 1 || 2500
101 || 41235 || pen || 2 || 1250
102 || 45324 || laptop || 1 || 7500
I have 50k records in line table.
Requirement is to have 25 records of header and the corresponding line details for that header information in each page.
The page should have 2 tables seperated. First table should show header information. Second table should be beneath the first table and should have line details information of the header 25 records.
How do i acheive this in SSRS using Report Builder?
Previous question:
I have 2 tables: Table 1- Header with 10k records and Table 2 line details corresponding to the header table and the number of records are 50k. The requirement is to display header on top of the page and line table beneath the header table. The details being displayed in the line table should correspond to the header table. The line and header table have a common field which is called uid(unique identifier). I need to create this report in SSRS Report Builder.
Work so far which i did:
1.) Created 2 datasets: Header and Line. Inserted a table for header and selected all the fields i will need to display. Likewise created another table for line and selected all the fields i need to display. The fields in line i used LOOKUP function pointing to the uid in header table and populated the data.
2.) I placed the line table just beneath the header.
3.) Since the number of records in header table are 10k, i restricted the rowcount to 50 so i can fit the header and line table in 1 page.
Issues i am facing:
1.) When i place the line table beneath the header table, i can't see the line table details, but when i place the line table next to header then i can see the detail of line table. I need the header table on top with 25 records and corresponding line details for that 25 header table records beneath the header table.
2.) The line table values are not being displayed in correspondence to the header table records being displayed in the page. which means if header table is displaying 25 records, the line table is displaying all the records. I need only the line details of the 25 header table records in that page.
Any help to solve this issue is greatly appreciated. Do let me know if you need any additional information. I am fairly new to IT and SSRS.

I think you might need to create a subreport for each group of 25 headers and the associated lines. Then create a master report to repeat for each group.
It's a bit long winded but should give you what you want.
First create a report that handles just a single "page" of results.
So, create a new report and add a dataset (call it something like dsHeaders with the following dataset query
SELECT * FROM (
SELECT
[UID], [Po_number], [Invoice Num], [Total Amount]
, [PageN] = (ROW_NUMBER() OVER(ORDER BY [UID]) - 1) /25
FROM myHeaderTable
) h
WHERE h.PageN = #p
This step should automatically create a report parameter for you called p
Now add a second dataset called dsLines with the following query...
SELECT * FROM (
SELECT d.*, p.PageN FROM myLinesTable d
JOIN ( SELECT
[UID], [Po_number], [Invoice Num], [Total Amount]
, [PageN] = (ROW_NUMBER() OVER(ORDER BY [UID]) - 1) /25
FROM myHeaderTable
) p
on d.UID = p.UID
) a
WHERE a.PageN = #p
This will give us all the lines along with the same PageN values as the headers. If required, you can adjust the number of lines in each page/group by adjusting the 25 in each query.
Now add two tables to the report and drag and drop the fields from dsHeaders into the first and the fields from dsLines into the second.
Run the report and test it by putting in different values for the p parameter.
Once you are happy with it, save the report.
Next.
Create a new report and add a dataset (called say 'dsMain') with the following dataset query.
SELECT
[UID], [PageN] = (ROW_NUMBER() OVER(ORDER BY [UID]) - 1) /25
FROM myHeaderTable
Now add a table and remove two of the three generated columns. In the remaining column, right click the textbox and do "Insert ==> Subreport".
Now right-click the new subreport placeholder and choose "Subreport properties"
In the first tab, click the drop-down and choose the subreport you created earlier.
Now click the parameters tab, Click Add and choose "p" (it should be in the drop-down list) as the parameter and choose the PageN field as the value (again this should be in the dropdown list.
if for some reason the drop downs are not working, simply type p into the name column and [PageN] into the value column.
Finally, go to the rowgroup panel under the main designer and right click the rowgroup shown there (there should only be 1 rowgroup).
Open the properties and select "Between each instance..." in the page break settings.
Now run the main report and you shoudl see the subreport generated for each group of 25 records.
That should give you the basic report.

Related

access 365 combo box selection adding a record to rowSource

I have a two column combo box on a form. The rowsource is set to a two column table. The table is GenderRef there are two fields; GenderSaid and Gender. GenderRef is related by GenderSaid to my People table. GenderRef has two records; GenderSaid = 1 and Gender = Male, GenderSaid = 2 and Gender = Female. When I run the form and select for example: Male from the combobox drop down then proceed to the next record, the GenderRef table has a new record added, GenderSaid = 3 and Gender = Male. I have run the cleanup and repair database utility. I have tried other properties. I have tried to change the relationship and even delete it but with the same result. I would use a value list but I will also be adding a few other reference combo boxes with more than two items in the list and want to get it right with the simplest one. The only VBA code I have runs an update query to the People table updating People.GenderSaid. I have commented out the entire VBA sub and still get a new record in GenderRef.

How to keep two dataset(grouping on each dataset) on one page

I have a requirement on which i need to show calender for each month with days on it and below this i need to show count for different services for that particular month. For this i have created two datasets
1> For the calender one
2> Different services for each month. Now I am not sure how to keep these two data sets on one page means
suppose its january month, so i need to show the calender for the January month and the total sevices for january month on one page and in the second page it will be show these two for februray month and it will go on. The number of months is controlled by a parameter .
What i have done now ?
For the 1st dataset the group is there and i have put page break after the group. And for the 2nd dataset, i have the group and put a page break after the group.
Please suggest how can i put these datasets on one page ( both are having group on the basis of month).
Thanks in advance.
Regards
Subrat
Here's a quick example.
NOTE: I'm using the AdventureWorks sample database here..
First we create the subreport. This will be a standard report but it will only produce results for a single month in our case. In this example I only pass in the month number as a parameter but obviously you might need to change that to pass in a year and/or other information.
I created a new report called Month Sub Report
I created two datasets that will give me sales by person and sales by territory for the same month. The queries I used are as follows.
-- query for dsSalesByPerson
select MONTH(OrderDate) as MonthNumber, SalesPersonID, p.LoginID , SUM(TotalDue) as Amount
from Sales.SalesOrderHeader s
join HumanResources.Employee p on s.SalesPersonID = p.BusinessEntityID
where datepart(yy, OrderDate) = 2013
and MONTH(OrderDate) = #MonthNumber
GROUP BY MONTH(OrderDate), SalesPersonID, p.LoginID
-- query for dsSalesByTerritory
select MONTH(OrderDate) as MonthNumber, t.Name as Terrotory , SUM(TotalDue) as Amount
from Sales.SalesOrderHeader s
join sales.Customer c on s.CustomerID = c.CustomerID
join sales.SalesTerritory t on c.TerritoryID = t.TerritoryID
where datepart(yy, OrderDate) = 2013
and MONTH(OrderDate) = #MonthNumber
GROUP BY MONTH(OrderDate), t.name
Note These both use the same parameter name with the EXACT same spelling, including case. As the create the datasets the parameter will be automatically created. If the name is the same on both databasets, only 1 parameter will be created which is what we want.
Next I added two simple tables and a textbox that looks like a header (actual headers don't work in subreports)
The final design looked like this.
When I run the subreport I get something like this.
Save and close this report design....
Next, create a new report, in this example I called it Month Master Report.
I created dataset called dsMonths with a list of months in (MonthNumber and MonthName) that we will use in our main report parameter to allow users to chose the months they want to report on.
I set the available values to point to our dsMonths dataset query and set it to allow multiple values (leave type as text)
Next create another dataset called dsMain. The query for this dataset needs to return a unique list of monthnumbers from your database so it might look something like
select DISTINCT MONTH(OrderDate) as MonthNumber
from Sales.SalesOrderHeader s
where datepart(yy, OrderDate) = 2013
and MONTH(OrderDate) IN (#Months)
ORDER BY MONTH(OrderDate)
Note: We use IN here as we are passing a list of #Months in.
Next, insert a table
Set the Dataset property og the table to dsMain
Next, remove the header row and all the column except 1.
Your table should have just a single 'cell' remaining. In this cell, right-click and insert a subreport.
Right-click the sub-report placeholder and choose properties.
Set the subreport used to be your subreport created earlier (i.e. Month Sub Report)
Click the parameters tab and then click "Add". Choose "MonthNumber" from under the name dropdown and your monthnumber fields from the value drop down list.
Next, double-click the "(Details)" row group nuder the main design window, click "Page Breaks" and select "Between each instance"
FINALLY! Mover the table to the top left corner of the page and shirk the report body so there is not lots of space around it (or this can cause unexpected page breaks)
When we run the report and choose a few Months we get the following, with each selected month on a new page (I'm only showing the last page in this image)
Hopefully that will give you enough to solve your issue.

SSRS - Report Builder -columns as rows

I have never used SSRS before.I need to create a new report.Query details from Employee table and display
in the below format for given emplID
Emplid 111
EmplName test
DateofBirth 1/1/1990
DateofHire 1/1/2015
DeptID 1
DeptName Sales
ManagerSignature --------------
Signed Date ------------
Also need to add custom fields that are not in the table like ManagerSignature and SignedDate.
I'm not sure how to get the above format.Any help is greatly appreciated.Thanks!
The simplest way to create a report with the two-column format you need is to add a table to the report.
Delete the last column so you only have two.
Right-click on the detail row (with the three lines like a hamburger menu icon) and Insert Row --> Inside Group.
Repeat Inserting Rows 6 more times to create all the detail lines you need.
The Left Column will be used as your Header and the 2nd column for your data. Add your Text headers to the first column and then chose the corresponding data field in the second.
In your query, add your signature and date line as null values so you can select it in your table just like the other values. Then add black bottom borders to those two text boxes to represent the signature/date lines.
select
Emplid
, EmplName
, DateofBirth
, DateofHire
, DeptID
, DeptName
, null as 'ManagerSignature'
, null as 'SignedDate'
from YourTable
Considering you have data something like below
Click on View and Report Data, There you can see your dataset and it'S column as well
Then go to Design area and then in body section Insert--> Table
You will have something like below
Then you will get option to enter data
Same way keep adding all others as well
Now on first row taye label per hand as below
At last you will have something like below
Remove unwanted column cell and row cell.
You will have something like below
Here's the tip,
Now if you want each record on each page
Click on Row deatils and then go to genral and add EmpId
and then add pagebreak as below
final result on each page each record result

SSRS Report with groups and page breaks

I am trying to write an SSRS report where the output is grouped by team, with each team starting on a new page, and on a new tab when the report is output to Excel. I want the column headers to repeat each time there is a new team, and at the top of each page if one team's data spans more than one page.
My test data is generated by the following code:
WITH
team_list(team_id,team) AS
(
SELECT 1, 'red'
UNION ALL SELECT 2, 'orange'
UNION ALL SELECT 3, 'yellow'
UNION ALL SELECT 4, 'green'
),
results1(result_value1) AS
(
SELECT 1
UNION ALL SELECT 2
UNION ALL SELECT 3
UNION ALL SELECT 4
UNION ALL SELECT 5
),
results2(result_value2) AS
(
SELECT 7*result_value1
FROM results1
),
main_query(id, team, value1, value2) AS
(
SELECT
tl.team_id
, tl.team
, r1.result_value1+20
, r2.result_value2
FROM
team_list tl CROSS JOIN results1 r1 CROSS JOIN results2 r2
WHERE
r1.result_value1 < tl.team_id+2
)
SELECT * FROM main_query
I want the report to look like this:
I inserted a Tablix with three columns: id, value1 and value2. I right-clicked on Details under "Row Groups", and did Add Group>Parent Group, Group by Team. I did not tick either "Add group header" or "Add group footer".
I clicked on Team under "Row Groups". Then in the Properties Window, which was showing "Tablix Member", I expanded Group and then Page Break, and set Page Break to Between. I also set PageName to Fields!team.Value.
To get the column headers to repeat, I clicked on the down arrow next to "Column Groups" and chose Advanced Mode. I clicked on the second occurrence of Static under "Row Groups" and in the Properties pane, set RepeatOnNewPage to True. I now had a report with a page break between teams, and it repeats the column headers on every page. When I exported it I got a tab for every team with the team name on it. Good.
Now, I do not want the first column of the table, Team. So I right-clicked the column and chose Delete Columns, then Delete Columns Only. I saw that under "Row Groups" the top "Static" had disappeared. My report no longer repeated the column headers on every page.
I tried hiding the two cells in the first column of the table, and this seemed to give the desired effect, apart from indenting the table to the right. I tried to set the width of this column to zero, which does not seem to be possible. When I exported the report I got a very narrow Column A. Is there any way of getting rid of this column altogether, while still having repeating column headers?
For my team heading, I inserted a row above the top row of the Tablix. I merged the three cells above my column headings. I right-clicked and added the expression ="Team " & Fields!team.Value. This displayed "Team red" for all the teams, instead of changing on each page. How can I make a heading row that will show the correct team name for each group?
You need an extra row in the team group. The easiest way is to do this is to add a header when you added your team group.
So in the 1st paragraph of your step-by-step..
from Details to Add Group -> Parent Group, select Team and check the add header option.
Double-click the new Team row group in the row group panel and set page breaks to between
Now you will have three rows in the table, ignore the fact that rows 2 and three are merged in column 1, we'll get rid of that once everything else is done.
Right-Click on one of the cells in row 2 (e.g. column 2 row 2) and choose Insert Row -> Inside Group - Above.
the table will look something like this..
Next copy the column hedaers (id, value1 and value2) to hte row direclty above the cells with the actual data in (should be row 3).
Then in row 2 select the three cells above your data column and merge them.
Select team as the field for this merged cell (or your expression)
It should now look something like..
Now delete the first row and first column as we don't need these anymore.
Next click the advanced mode from the drop down next to the column groups as you did before.
Select the two static items in the ROW GROUPS and set the "RepeatOnNewPage" to true.
Finally, for testing, I set the interactive size height property of the report to 10cm (so I could force some page breaks before then end of each group).
After following this, the report worked as expected, below you can see the 2nd page for yellow has the correct header.
In case it's useful, I used Report Builder 2016 to build the sample RDL. You can get hold of it here, you'll just need to edit the connection properties to get it to run.
Link to GroupHeaderRepeat.rdl
https://1drv.ms/u/s!Al1Kq21dFT1ijb5Qmm2P4zyM1MV4pA

SSRS report - add extra table and chart to show occurence of character string in one of the main report's columns

I have an SSRS report based on stored procedure dataset. The report shows employees and their performance rating and uses bunch of parameters to filter the data.
Now I would like to add a table below that would dynamicaly count and show occurence of given mark in the main report. The table data should update according to what is visible in the main report after filtering it.
I wanted also to add a chart that would visualize this.
It would be feasible to do if the extra table and chart could run from the same dataset as the main report. This however seems impossible as this dataset does not always contain all the possible marks. It can happen that some marks are missing (when filtered or missing at all), and I would like to show the mark with zero value (and zero value bar in the chart) instead of just skipping it.
So far I was able to produce the table by hardcoding the headers and using SUM(IIF...) expressions under each header
Here is the expression for the "C" column.
=Sum(IIf(Fields!current_performance_rating.Value = "C", 1, 0))
It shows correctly the number of "C" marks appearing in the main report.
Now I am stuck with creating a chart that would show this.
I am not able to hardcode expressions similar to the ones in the table
and can't make the chart run from the main dataset, because the categories
would be missing after filtering the report (and not showing zero).
I tried linking datasets with Lookup function, but that did not work.
Which way should I go now? What is the best practice in such case?
Thank you for any hints!
Thanks trubs.
I have right joined a view that contains
all the marks and that solves the issue
of missing categories.
The join is on something like
tb.current_performance_rating = vw.performance_rating_code
I can now add the value series that counts
the occurence of current_performance_rating
per category. This works all fine.
However there is another table joined
(on employee_id) that stores last year's rating.
This rating obviously may differ to the current one.
On the same chart I would like to add another
series that counts last year's rating per category.
The category is there already, joined to the current
rating.
So you can have row like:
curren rating | last year's rating | category
C | H | C
So I am stuck, because when SSRS groups per category
it counts last year's H rating and displays
i the C category, while it should display it in H.
Sorry I can't post any pictures, seems like I
need more reputation points.
Hope you can understand what I mean.
Regards!
You're likely better off changing your query to return results for marks where there are no values.
So instead of inner joining to your Performance Rating table, use a Right Join or Full Outer Join, so that all the data is always available.
eg: Instead of...
SELECT p.PersonId, PersonName, g.Grade
FROM Person p
INNER JOIN PersonGrades pg ON p.PersonId = pg.PersonId
INNER JOIN Grades g ON pg.GradeId = pg.GradeId
Use
SELECT p.PersonId, PersonName, g.Grade
FROM Grades g
LEFT JOIN PersonGrades pg ON pg.GradeId = g.GradeId
LEFT JOIN Person p ON p.PersonId = pg.PersonId
If that's not clear, post your query and we could help get the data in the right format.
The way to go was to simplify the dataset that the main report was based on.
Then I took the query from that dataset, used COUNT and GROUB BY to count number of occurence of each current year mark in the main report. Then I right joined (thx trubs!) with the view that contains all the possible marks (so that my extra table headers/chart categories would not disappear if they do not exist). As a result I got the number of occurence in current year per mark (table A).
Then I did almost exactly the same for the last year's rating, just used last year's mark. I got the number of occurence of last year's mark per mark (table B).
I inner joined table A and B on common column (the mark, which will always appear thanks to the RIGHT joins). This gave me a table (dataset eventualy) where I had:
mark | current year mark count | last year mark count.
Making a table and chart basing on this was really easy then.
There was some more fun of adding all the parameters from the main report to both the count queries, so that the counts would change when report is filtered. I also needed to make sure that count works not only when my filter criteria (in WHERE stetement) equal the parameter provided from the report, but also when they are NULLs (so I added OR column_i_filter_on IS NULL).
This works smoothly - the table content and chart changes when filtering changes (although runs slowly, as parameters are passed to two big dataset, one of which uses them twice).
Thanks for all the help!!
psh