SSRS - Report Builder -columns as rows - reporting-services

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

Related

Issues with displaying 2 tables in SSRS in a single page

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.

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

Splitting column into two columns with different string counts in MySQL

I have a table ML, with column Klubs:
I want to split this column so I have two columns like this. New table name ML2 and column name Region.
First column can have 2 words if they are different from 2nd column word.
I am new to MySQL and searched all over stackoverflow and internet , but no luck.
How can split column Klubs from table ML as in 1st picture into new table ML2 with 2 columns as in 2nd picture?
Assuming that your second column does not include any spaces, we can search for the location of the last space, and then split there:
SELECT Klubs,
substr(Klubs, 1, char_length(Klubs) - instr(reverse(Klubs),' ')) as Region,
substr(Klubs, char_length(Klubs) - instr(reverse(Klubs),' ')+2) as Club
FROM ML;
I search for the the space with instr, and to do this reverse I use the reverse function on the string first, and then to compensate I subtract it from the length of the string with char_length.
You could insert it in a new table (ML2):
create table ML2
<the query>
or create a view:
create view ML2 as
<the query>

Adding values to a Report when there is no Data in query SSRS

I have a query that returns Sales representatives number, Category, Sales.
The result is something like this:
There are 4 categories called G1,G2,G3,G4.
As you can see the Sales representative 11 sold 10 each category (Yellow rows).
But Representative 12 sold only for category G3 and G4.
The idea is to show in the report all the categories and populate with 0 all those who did not sell on that particular category.
It must be grouped by Sales Representative so if you make a tablix grouping by Sales Representatives you will have something like this:
But you want something like this:
Is there any expression I could use to add these?
What I did so far is to create a group, that group of course are my Sales representatives and combine the cells for that Column and created a Row group for each category, is something like this:
But if you execute that report it will repeat all categories G1,G2... For each time that category exists for that particular Sales Representative.
Another problem is, how can you evaluate The hardcoded category in your report if it does not exist in your datasource you cant make Iif("G1" = Fields!Category.Value,Fields!Sales.Value,"0") as you are not comparing G1 with Null or IsNothing, you are comparing what it exists.
I think you can achieve this smoothly using T-SQL at query level. I don't know why you don't use the simplest way to apply this kind of logic since in T-SQL you can use almost every logic.
However I like this kind of challenges so I come with this possible solution.
This is my sample dataset:
In SSRS dataset (not in T-SQL) I've added a calculated field called Another
Another field is set to the below expression:
=Fields!SalesRep.Value & "-" & Fields!Category.Value
I've added a tablix with the following data arrangement
As I mentioned before category field is hardcoded, the right column with Sales
is set to this expression:
=iif(IsNothing(lookup(Fields!SalesRep.Value & "-" & ReportItems!Textbox62.Value,
Fields!Another.Value,Fields!Sales.Value,"DataSet7")),0,
lookup(Fields!SalesRep.Value & "-" & ReportItems!Textbox62.Value,
Fields!Another.Value,Fields!Sales.Value,"DataSet7"))
Note: ReportItems!Textbox62.Value corresponds to textbox where G1
was hardcoded. You have to replace the textbox reference for the
corresponding in your tablix for every category.
It will preview the below tablix.
Let me know if this was helpful.

Microsoft Access question

I have a combo box which has 3 pieces of information
COMBO BOX 210: Materials ID, Name of Product, Cost, Description
After I update the combo box the cost figure is stored in another field in the table, so far so good, so in selecting "Apples" the cost "$1" stores.
Now, what I want to is have a different field where the description of the apple (the text) is stored yet I only update the combo box once, in other words after updating the combo box Field 1 stores the price and Field 2 the description of the apple.
I will offer you a different example which I hope is similar to what you're asking.
My form includes a combo named cboNames. This is the query for its row source:
SELECT f.id, f.fname, f.date_added
FROM food_test AS f
ORDER BY f.fname, f.date_added;
In the combo's After Update event I can access the values of those 3 columns in the selected combo row by referring to the Column index. Notice the column index numbering starts with zero.
Private Sub cboNames_AfterUpdate()
Debug.Print Me.cboNames.Column(0)
Debug.Print Me.cboNames.Column(1)
Debug.Print Me.cboNames.Column(2)
End Sub
So if I wanted to put the date_added value into another data control, I could add this to the combo's After Update event.
Me.SomeOtherControl = Me.cboNames.Colummn(2)
However I wouldn't actually store both id and date_added in a row of another table. In my food table, each id is associated with a unique combination of fname and date_added. So I would store only the id, and use a SELECT with a JOIN to the food table to look up the associated fname and date_added values whenever I needed them.